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

@@ -18,11 +18,10 @@ var scriptURLText = regexp.MustCompile(`(?i)(?:^|[^a-z0-9+.\-])(?:(?:javascript|
// UnsafeText reports whether a text that a layout prints, such as the site
// name of the built-in layouts, must be kept out of mail. A text is unsafe
// when, HTML-escaped as html/template prints text, it fails the rendered-HTML
// safety checks in the places the built-in layouts print it (for example
// event-handler-shaped text such as "Shop onclick=x", or "Online=Shop" after
// the footer's "© <year> "), or when it holds a script URL: javascript: or
// vbscript: at a scheme boundary, or a data: URL. "Big Data: Summit" is safe;
// "javascript: Acme" is not.
// safety checks in the places the built-in layouts print it, or when it holds
// a script URL: javascript: or vbscript: at a scheme boundary, or a data:
// URL. Escaped text is never markup, so "Big Data: Summit", "Online=Shop" and
// "Shop onclick=x" are safe; "javascript: Acme" is not.
func UnsafeText(s string) bool {
return validateHTML(printContext(html.EscapeString(s))) != nil || scriptURLText.MatchString(s)
}