fix(postcard): check URL schemes in decoded attribute values, not in text
- validateHTML keeps the raw tag and handler regexes and reads the rest through unsafeMarkup: x/net/html tokenizer, decoded attribute values, prefix check on URL attributes, whole-value check on CSS, list attributes, meta content and comments; any on* attribute is refused - text is not a URL: "Metadata: Weekly" or "Big Data: Summit" as a site name or body text no longer stops a send (CR-01) - entity-encoded javascript: is refused whether or not the layout opts out of inlining (WR-05) - draft layout CSS is checked as a style element - fixtures that pinned prose as unsafe now carry markup-level URLs; the 35-07 subtest pinning an unsafe stored name is removed - TestMailSafetySmoke prose_site_name and encoded_scheme
This commit is contained in:
@@ -244,8 +244,10 @@ func (e *Editor) renderLayout(d Draft, ov Overrides, opts renderOptions) (Render
|
||||
if loc := closingStyle.FindStringIndex(d.CSS); loc != nil {
|
||||
return RenderedMessage{}, &DraftError{Field: fieldContentCSS, Rule: ruleUnsafe, Message: snippetAt(d.CSS, loc)}
|
||||
}
|
||||
// The CSS is placed in a style element; check it as one, so the scheme
|
||||
// check reads it.
|
||||
var unsafe *unsafeError
|
||||
if err := validateHTML(d.CSS); errors.As(err, &unsafe) {
|
||||
if err := validateHTML("<style>" + d.CSS + "</style>"); errors.As(err, &unsafe) {
|
||||
return RenderedMessage{}, &DraftError{Field: fieldContentCSS, Rule: ruleUnsafe, Message: unsafe.snippet}
|
||||
}
|
||||
// A wrapper that does not parse is reported by the render below.
|
||||
|
||||
Reference in New Issue
Block a user