v2.8.1 — fix prepend dropping the body, and plain-text inserts - #223
Merged
Conversation
"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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 frontof the
<html>/<body>wrapper thatgetComposeDetails()returns. Thunderbird128 and 140 ESR rebuild the compose document from that string and read the head
from
<headand the body from<bodyonwards — anything ahead of those markersbelongs 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, wherethe 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.bodywhen the composer is in plain-text mode andexpects
plainTextBody. TemplateWing only ever setbody, so subject andrecipients 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:
269 unit tests pass (up from 260), locales consistent, formatting clean.