Sanitizer: a newsletter's <title> showed as a line above the body

<title> is not an allowed tag, so nh3 unwrapped it and kept its text —
"mailer", "Email template" or the subject rendered before the content.
It is now dropped with its content, both in the sanitized HTML and in the
text derived from HTML-only mail (snippet and search). SANITIZER_VERSION
goes to 4 so stored bodies re-sanitize from the raw blob on next render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 20:35:42 +02:00
co-authored by Claude Opus 5.5
parent fcafc6a026
commit 02011f23f6
4 changed files with 33 additions and 4 deletions
+7
View File
@@ -75,6 +75,13 @@ def test_html_only_derives_text() -> None:
assert "<b>" not in parsed.text_body # tags stripped for indexing text
def test_html_only_text_skips_document_title() -> None:
parsed = parse_message(
_build(text=None, html="<html><head><title>mailer</title></head><p>Hello</p></html>")
)
assert parsed.snippet == "Hello"
def test_multipart_alternative_prefers_html_for_display() -> None:
parsed = parse_message(_build(text="text version", html="<p>html version</p>"))
assert parsed.html_body is not None