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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user