c01de718b2fb8e7706a0fede0e5ea4149ac6f378
braney
Mon Aug 31 13:48:13 2026 -0700
htmlSanitize: six fixes from a second review of it, refs #38126
Filter the style attribute on the text a browser will see. A browser turns a
character reference into the character it names before the CSS parser runs, so
a value spelled url( reached the page as url( and walked past the check
that is there to stop it. The value is decoded before the check now, and the
author is told which property lost its value.
Say something when we drop the rest of the page. A tag that never ends, most
often an attribute value whose quote is never closed, threw away everything
after it and reported nothing, so hubCheck stayed quiet about it. The depth
cap did the same.
Write a less than sign that starts no tag as <. A browser reads text like
" " as a comment and swallows markup of ours up to the next '>', which could
eat a closing tag we added.
Write an attribute once. A browser keeps the first of a repeated attribute and
drops the rest. We checked the first and then printed them all, which was only
correct because of that rule.
Do not stack a second descPage- prefix on an id we already renamed, and do not
add a second noopener noreferrer to a rel that already has one. hgCustom hands
the text we returned back to us when a custom track is edited and saved again,
so both of these grew a little more on every save.
The test now re-runs the filter over its own output and prints any case that
changes, so a transform that compounds shows up in the diff.
diff --git src/lib/tests/htmlSanitizeTest.c src/lib/tests/htmlSanitizeTest.c
index 5f18da8167a..cd081f855cd 100644
--- src/lib/tests/htmlSanitizeTest.c
+++ src/lib/tests/htmlSanitizeTest.c
@@ -38,37 +38,63 @@
"
the rest of the page is not inside that div",
/* a page built of tags that are never closed is not a way to make us work all day */
"