Skip to content

fix: render portal contact-form html instead of escaping it#133

Merged
albanm merged 2 commits into
masterfrom
fix-portal-contact-mail
Jun 19, 2026
Merged

fix: render portal contact-form html instead of escaping it#133
albanm merged 2 commits into
masterfrom
fix-portal-contact-mail

Conversation

@albanm

@albanm albanm commented Jun 19, 2026

Copy link
Copy Markdown
Member

The #123 mail-hardening commit switched the anonymous /api/mails/contact
route to textToSafeHtml, which HTML-escapes the whole body. But the portal
contact form composes an HTML body client-side (lists, bold labels, line
breaks, optional bodyTemplate_html) and posts it in the text field, so
recipients started seeing raw tags instead of rendered structure.
Use sanitizeMailHtml on the contact route instead: structure renders while
scripts and non-http(s)/mailto hrefs are stripped. Test and
docs/architecture/emails.md updated to match.

Why: portal contact emails regressed to showing raw HTML after the mail
hardening pass; this restores rendering without reopening the injection path.

Heads-up: the body is partly anonymous-visitor-controlled, so the
server-side sanitizer (not raw passthrough) is the trust boundary. Unlike the
previous escape path, sanitizeMailHtml does not turn \n into <br>, so
the plain-text contact-form prefix no longer line-breaks in the HTML part —
cosmetic only.

albanm and others added 2 commits June 19, 2026 14:47
The #123 mail-hardening commit switched the anonymous /api/mails/contact
route to textToSafeHtml, which HTML-escapes the whole body. But the portal
contact form composes an HTML body client-side (lists, bold labels, line
breaks, optional bodyTemplate_html) and posts it in the `text` field, so
recipients started seeing raw tags instead of rendered structure.

Use sanitizeMailHtml on the contact route instead: structure renders while
scripts and non-http(s)/mailto hrefs are stripped. The body is partly
anonymous-visitor-controlled, so the sanitizer stays the trust boundary
rather than reverting to raw passthrough.

Update the test and docs/architecture/emails.md (invariants 3-4 and the
contact-endpoint section) to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@albanm albanm changed the title Fix portal contact mail fix: render portal contact-form html instead of escaping it Jun 19, 2026
@albanm albanm merged commit 7733092 into master Jun 19, 2026
5 checks passed
@github-actions github-actions Bot added the fix label Jun 19, 2026
@albanm albanm deleted the fix-portal-contact-mail branch June 19, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant