From 31de2ff90fb90585907a57bc5d8cbba1ef299065 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sat, 14 Nov 2026 17:37:52 +0100 Subject: [PATCH] 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=. --- docs/services/mail.md | 4 +- .../cabana/mail_site_name_postgres_test.go | 26 +++++---- modules/phrasebook/backend/lang/en/lang.yaml | 2 +- modules/phrasebook/backend/lang/pl/lang.yaml | 2 +- modules/postcard/README.md | 6 +-- modules/postcard/override_smoke_test.go | 8 +-- modules/postcard/safety.go | 9 ++-- modules/postcard/safety_smoke_test.go | 10 ++-- modules/postcard/safety_test.go | 5 ++ modules/postcard/sitename_test.go | 53 ++++++++++++------- modules/postcard/templates.go | 13 ++--- 11 files changed, 79 insertions(+), 59 deletions(-) diff --git a/docs/services/mail.md b/docs/services/mail.md index bdf3ef8e..fb32dfb2 100644 --- a/docs/services/mail.md +++ b/docs/services/mail.md @@ -85,7 +85,7 @@ The settings also hold a logo. A layout shows it where it uses `{{ .logoUrl }}`: The settings also hold a site name, given to layouts as `{{ .siteName }}`. The built-in layouts show it in the header (as the logo's alternative text when there is a logo) and in the footer. Left empty, the display name of `mail.from` is used (`Acme` for `Acme `), so mail from an application that never saved Branding still carries a name. -A site name mail could not show safely is refused when the settings are saved: one holding a `javascript:`, `vbscript:` or `data:` address, or text that would read as markup where the layouts print it, such as `onclick=`, or `Online=Shop`, which the footer prints after `© `. Ordinary text with a colon, such as `Big Data: Summit`, is accepted. A name stored before this check, or a `mail.from` display name of that kind, is left out of mail at send time (the next name in line is used, or none), with a warning in the log; the message is still sent. +A site name mail could not show safely is refused when the settings are saved: one holding a `javascript:`, `vbscript:` or `data:` address. Ordinary text with a colon, such as `Big Data: Summit`, and text such as `Online=Shop` or `onclick=` are accepted: the layouts print the name as escaped text. A name stored before this check, or a `mail.from` display name of that kind, is left out of mail at send time (the next name in line is used, or none), with a warning in the log; the message is still sent. A mail client needs an absolute address, so the logo's URL is built at send time from the configuration: `storage.uploads.public_url` when it is set, otherwise `app.url` with `storage.uploads.public_path_prefix`; see [Absolute URLs for mail](storage.md#absolute-urls-for-mail). Set one of them, or the logo is left out and a warning is logged. @@ -155,7 +155,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 `