From 13ab905f8d86d2e1ace469a3d332bec2812a8144 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sat, 14 Nov 2026 15:13:35 +0100 Subject: [PATCH] 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 --- docs/services/mail.md | 2 +- .../cabana/mail_brand_layout_postgres_test.go | 12 -- modules/postcard/README.md | 8 +- modules/postcard/editor.go | 4 +- modules/postcard/editor_smoke_test.go | 6 +- modules/postcard/override_smoke_test.go | 7 +- modules/postcard/override_test.go | 11 +- modules/postcard/partials_smoke_test.go | 20 ++- modules/postcard/safety.go | 125 ++++++++++++++++++ modules/postcard/safety_smoke_test.go | 104 +++++++++++++++ modules/postcard/templates.go | 13 +- 11 files changed, 277 insertions(+), 35 deletions(-) create mode 100644 modules/postcard/safety.go create mode 100644 modules/postcard/safety_smoke_test.go diff --git a/docs/services/mail.md b/docs/services/mail.md index 5616b245..666ab50b 100644 --- a/docs/services/mail.md +++ b/docs/services/mail.md @@ -153,7 +153,7 @@ fmt.Println(err != nil, len(driver.Messages())) postcard does not pick a locale: the caller passes the full name. A per-language version of a template is a file named after the template, a dash and the locale (`welcome-en.htm`, sent as `acme.blog::mail.welcome-en`). A name with its own file always renders that file. A name the catalog does not hold, of the form `