Skip to content

v2.8.1 — fix prepend dropping the body, and plain-text inserts - #223

Merged
JuliaKalder merged 3 commits into
mainfrom
fix/221-prepend-drops-body
Aug 11, 2026
Merged

v2.8.1 — fix prepend dropping the body, and plain-text inserts#223
JuliaKalder merged 3 commits into
mainfrom
fix/221-prepend-drops-body

Conversation

@JuliaKalder

Copy link
Copy Markdown
Owner

Bugfix release v2.8.1 with two fixes for templates that never made it into the message.

"Insert at beginning" dropped the template body (#221)

The new body was built as template + existing, which puts the template in front
of the <html>/<body> wrapper that getComposeDetails() returns. Thunderbird
128 and 140 ESR rebuild the compose document from that string and read the head
from <head and the body from <body onwards — anything ahead of those markers
belongs to neither and is discarded. Append survived by accident, because trailing
content still falls inside the body slice.

Thunderbird 153 replaced that path with documentElement.innerHTML = body, where
the parser folds stray leading text into the body. That is why the bug is invisible
on current release builds and only hits the ESR channel — which is most users.

The template is now spliced inside the body element, for both "Insert at
beginning" and "Append". A bare fragment without a wrapper still falls back to
plain concatenation.

Templates were never inserted in plain-text compose windows (#222)

Thunderbird deletes details.body when the composer is in plain-text mode and
expects plainTextBody. TemplateWing only ever set body, so subject and
recipients arrived while the text was silently dropped — in every insert mode, on
every Thunderbird version. Two follow-on problems from the same mix-up are fixed
alongside: the cursor-mode fallback merged into the HTML rendering instead of the
real text, and a default template could never auto-insert on a plain-text account.

Verification

Reproduced and re-tested in a throwaway Thunderbird 140.13.0esr profile, driven
through the real popup UI, reading the saved draft off disk:

Case 2.8.0 2.8.1
HTML, prepend body missing body on top, above the signature
HTML, replace body present (control)
Plain text, prepend draft holds only the signature body on top, above the signature

269 unit tests pass (up from 260), locales consistent, formatting clean.

JuliaKalder and others added 3 commits August 11, 2026 21:24
"Insert at beginning" built the new body as `template + existing`, which
puts the template in front of the `<html>`/`<body>` wrapper that
getComposeDetails() returns. Thunderbird 128/140 ESR rebuild the compose
document via HTMLEditor::RebuildDocumentFromSource, which takes the head
from `<head` and the body from `<body` to the end of the string — anything
ahead of those markers is in neither substring and is discarded. The body
never arrived; subject/to/cc did, which is exactly what the reporter saw.

Append survived by accident: trailing content still falls inside the
`<body …>`-to-end substring. TB 153 replaced that path with
`documentElement.innerHTML = body`, where the parser folds stray leading
text into the body — so the bug is invisible on current release builds and
only bites the ESR channel, i.e. most users.

insertHtmlAtBodyStart/insertHtmlAtBodyEnd now splice the template inside
the body element; a bare fragment without a wrapper still falls back to
plain concatenation, so nothing changes there.

Verified end-to-end on a throwaway TB 140.13.0esr profile: 2.8.0 prepend
drops the text, 2.8.0 replace keeps it, 2.8.1 prepend keeps it above the
signature.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Thunderbird deletes `details.body` when the composer is in plain-text mode
(mail/components/extensions/parent/ext-compose.js) and expects
`plainTextBody` instead. TemplateWing only ever set `body`, so on a
plain-text account the subject and recipients arrived while the template
text was silently dropped — in every insert mode, on every Thunderbird
version. Reproduced on TB 140.13.0esr: the saved draft contained nothing
but the signature.

Plain-text composers now receive the template as `plainTextBody`, flattened
via htmlToPlainText, joined to the existing text with exactly one newline.
Two related mix-ups fixed alongside:

- The cursor-mode fallback merged its plain text into `existingDetails.body`,
  which holds an HTML rendering on a plain-text composer; it now reads
  `plainTextBody`.
- maybeApplyDefaultTemplate ran the plain-text emptiness heuristics against
  that same HTML rendering, so a default template could never auto-insert on
  a plain-text account.

Verified on TB 140.13.0esr: 2.8.0 saves a draft holding only the signature,
2.8.1 puts the template above it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@JuliaKalder
JuliaKalder merged commit 20c45a5 into main Aug 11, 2026
1 check passed
@JuliaKalder
JuliaKalder deleted the fix/221-prepend-drops-body branch August 11, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant