fix(35): WR-02 drop the whole-document event-handler regex

validateHTML ran (?i)\son[a-z]+\s*= over the rendered document, text
included, so a variable such as "buy one = get one free" stopped its own
message, and it is what made Online=Shop in the footer a send failure.
The tokenizer walk refuses every on* attribute, and since CR-02 it also
reads raw-text element and comment content as markup, so the regex is
dropped. Text shaped like a handler is now sent; such site names are shown
and saved, and the Branding refusal copy no longer mentions onclick=.
This commit is contained in:
Jakub Zych
2026-11-14 17:37:52 +01:00
parent baba524caf
commit 31de2ff90f
11 changed files with 79 additions and 59 deletions

View File

@@ -29,6 +29,10 @@ func TestURLSchemeCheck(t *testing.T) {
{"textarea_escaped_link", `<textarea>&lt;a href="javascript:x"&gt;</textarea>`},
{"title_escaped_link", `<svg><title>&lt;a href="javascript:x"&gt;</title></svg>`},
{"noscript_safe_link", `<noscript><a href="https://example.com/">Open</a></noscript>`},
// Text shaped like an event handler is text (WR-02).
{"prose_handler_shaped", `<p>Ada, buy one = get one free, online = yes</p>`},
{"footer_handler_shaped_name", `<p>© 2026 Online=Shop</p>`},
{"title_escaped_handler", `<svg><title>&lt;img onerror=x&gt;</title></svg>`},
{"outlook_conditional_vml", `<!--[if mso]><v:roundrect href="https://example.com/" style="height:40px"><w:anchorlock/></v:roundrect><![endif]-->`},
}
for _, tc := range accepts {
@@ -67,6 +71,7 @@ func TestURLSchemeCheck(t *testing.T) {
{"entity_first_letter", `<a href="&#106;avascript:alert(1)">x</a>`, `&#106;avascript:alert(1)`, schemeMsg},
{"tab_split", `<a href="java&#9;script:alert(1)">x</a>`, `java&#9;script:alert(1)`, schemeMsg},
{"newline_split", `<a href="java&#x0A;script:alert(1)">x</a>`, `java&#x0A;script:alert(1)`, schemeMsg},
{"handler_with_space", `<p class="x" onclick="x()">x</p>`, `onclick="x()"`, "event handlers"},
{"handler_without_space", `<img src="x.png"onerror="alert(1)">`, `onerror="alert(1)"`, "event handlers"},
// Raw-text element content that a mail client parses as markup
// (scripting off, foreign content in svg) (CR-02).