From f1d22353ca511f1b7ec0e1c434fba2dc842eec3f Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sat, 14 Nov 2026 16:18:18 +0100 Subject: [PATCH] docs(35): re-review gap closure - CR-01 residual and scheme-check bypass found --- .../35-REVIEW.md | 243 ++++++++---------- 1 file changed, 109 insertions(+), 134 deletions(-) diff --git a/.planning/phases/35-mail-templates-and-layouts-editor/35-REVIEW.md b/.planning/phases/35-mail-templates-and-layouts-editor/35-REVIEW.md index d6f355b7..dcd24ea9 100644 --- a/.planning/phases/35-mail-templates-and-layouts-editor/35-REVIEW.md +++ b/.planning/phases/35-mail-templates-and-layouts-editor/35-REVIEW.md @@ -1,201 +1,176 @@ --- phase: 35-mail-templates-and-layouts-editor -reviewed: 2026-11-13T18:30:00Z +reviewed: 2026-11-14T15:16:46Z depth: standard -scope: incremental (gap closure 35-05, 35-06, 35-07; diff 593f99ac..HEAD) -files_reviewed: 52 +scope: re-review of gap closure 35-08 / 35-09 (diff 75669b34..HEAD), fixes for CR-01, WR-01, WR-05 of the previous report +files_reviewed: 25 files_reviewed_list: - - admin/openapi/admin.json - - admin/src/api/schema.d.ts - - admin/src/components/form/LocaleVariantSwitcher.vue - - admin/src/views/FormView.vue - - admin/tests/form/FormViewMail.test.ts - - admin/tests/form/LocaleVariantSwitcher.test.ts - - docs/backend/forms.md - docs/services/mail.md - - go.mod - - go.sum - modules/cabana/README.md - - modules/cabana/backendscreens/controllers/mailtemplates/_info.htm - - modules/cabana/backendscreens/controllers/mailtemplates/config_filter.yaml - - modules/cabana/backendscreens/models/mailbrandsetting/fields.yaml - - modules/cabana/backendscreens/models/maillayout/fields.yaml - - modules/cabana/backendscreens/models/mailtemplate/columns.yaml - - modules/cabana/crud.go - modules/cabana/mail_admin.go - modules/cabana/mail_brand_layout_postgres_test.go - - modules/cabana/mail_lifecycle_postgres_test.go - - modules/cabana/mail_locale_postgres_test.go - - modules/cabana/mail_routes.go - modules/cabana/mail_screens_smoke_test.go - - modules/cabana/mail_unit_test.go - - modules/cabana/relation_field.go + - modules/cabana/mail_site_name_postgres_test.go + - modules/cabana/settings.go - modules/phrasebook/backend/lang/en/lang.yaml - modules/phrasebook/backend/lang/pl/lang.yaml - modules/postcard/README.md - - modules/postcard/assets/brand.css.tmpl - modules/postcard/assets/default.htm - - modules/postcard/assets/minimal.htm - modules/postcard/assets/partials/footer.htm - - modules/postcard/assets/partials/header.htm - modules/postcard/assets/system.htm - - modules/postcard/brand.go - - modules/postcard/brand_smoke_test.go - - modules/postcard/brand_test.go - modules/postcard/editor.go - modules/postcard/editor_smoke_test.go - - modules/postcard/inline.go - - modules/postcard/inline_test.go - - modules/postcard/layouts_test.go - - modules/postcard/locale_postgres_test.go - - modules/postcard/locale_test.go - modules/postcard/mailer.go - - modules/postcard/mailer_test.go - modules/postcard/override_smoke_test.go - modules/postcard/override_test.go - modules/postcard/partials_smoke_test.go - - modules/postcard/store.go + - modules/postcard/safety.go + - modules/postcard/safety_smoke_test.go + - modules/postcard/safety_test.go + - modules/postcard/sitename_test.go - modules/postcard/templates.go - scripts/check-phase35.sh findings: - critical: 1 - warning: 5 - info: 4 - total: 10 + critical: 2 + warning: 3 + info: 3 + total: 8 status: issues_found --- -# Phase 35: Code Review Report (gap closure 35-05 / 35-06 / 35-07) +# Phase 35: Code Review Report (re-review of gap closure 35-08 / 35-09) -**Reviewed:** 2026-11-13T18:30:00Z +**Reviewed:** 2026-11-14T15:16:46Z **Depth:** standard -**Files Reviewed:** 52 +**Files Reviewed:** 25 **Status:** issues_found -This report supersedes the earlier 35-REVIEW.md (2026-11-13T13:39:18Z, plans 35-01..35-04). It reviews the incremental scope `593f99ac..HEAD`: one admin record per mail template with a locale switcher (postcard `TemplateFor`, `EnsureLocaleRows`, the `base_code` migration, cabana grouping, the switcher), the WinterCMS default layout with header/footer partials, `Brand.SiteName`, CSS inlining via go-premailer with a per-layout opt-out, and the 35-07 tests and `check-phase35.sh` consumer stage. Earlier findings for files outside this diff are not re-stated here. +This report replaces the 2026-11-13 report (still in git history at `75669b34:.planning/phases/35-mail-templates-and-layouts-editor/35-REVIEW.md`). It re-reviews the gap-closure diff `75669b34..HEAD`: +- the tokenizer-based URL-scheme check (`modules/postcard/safety.go`), +- `postcard.UnsafeText` and the drop of unsafe site names at render time, +- the Branding save rule, +- the literal footer `text` argument, +- the inliner fallback, +- the 35-09 tests and `check-phase35.sh` gate entries. + +Findings from the previous report for code outside this diff (WR-02, WR-03, WR-04, IN-01, IN-02, IN-04) were not part of the gap closure and are not repeated here. Spot checks show they are still open (for example `scopeTemplates` at `modules/cabana/mail_admin.go:520`, and `mailLocales` still calling `w.EnabledLocales(ctx, db)` on the request transaction at line 188). + +Every claim below was confirmed by probe tests run through `go test -overlay` (scratch test files mapped into `modules/postcard`). No source file was changed. `go test -short ./modules/postcard ./modules/cabana` passes. ## Summary -The locale-group model is mostly consistent. Send resolution, the admin's `base_code` grouping, reset, drift stamping and the switcher agree on what a fallback-locale row is. Inlining is wrapped with panic recovery and degrades to the style block on inliner errors. The vue switcher reverts correctly on a refused navigation, and FormView is remounted per path, so variants never go stale. +**CR-01 is only partly resolved.** The colon case is fixed: `Big Data: Summit` and `Metadata: Weekly` now render and send. Unsafe names are dropped at render, and the Branding form refuses them. But `UnsafeText` checks the name on its own, while the footer prints it after `© `. A name starting with `on=`, such as `Online=Shop` or `onboarding=team`, passes `UnsafeText` and is saved. In the footer it then matches the whitespace-prefixed `eventHandler` regex, and every send on the default and system layouts fails, as in the original CR-01. This happens for a Branding name and for a `mail.from` display name alike (CR-01 below). -The main defect is the known site-name item. Its impact is wider than recorded. The check that fails is the unanchored `dangerousScheme` regex, so ordinary names such as "Big Data: Summit" or "Metadata: Weekly" fail it. The same name taken from `mail.from` breaks every built-in-layout send after an upgrade, with no admin action. It also blocks saving any template or layout in the admin. I confirmed this with a probe test run through a `go test -overlay` that changed no source. Other issues: the site name is rendered as Markdown in the footer. Lock ordering in the show and save transactions can deadlock. A swallowed error inside a Postgres transaction leaves it aborted. The fallback rule silently accepts typos while rejecting real 3-letter locales. The safety check runs before entity decoding, which the new opt-out now exposes. +**The URL-scheme check can still be bypassed, without any encoding.** `x/net/html`'s tokenizer, used on its own, reads `noscript`, `title`, `textarea`, `xmp`, `noembed`, `noframes`, `plaintext` (and `style`) contents as raw text. `unsafeMarkup` only inspects raw text inside `style`. A mail client renders with scripting off, so it parses `