feat(signature): add HTML signature support#10876
Open
joshua-grimmett wants to merge 1 commit intothunderbird:mainfrom
Open
feat(signature): add HTML signature support#10876joshua-grimmett wants to merge 1 commit intothunderbird:mainfrom
joshua-grimmett wants to merge 1 commit intothunderbird:mainfrom
Conversation
Add a per-identity "Format signature as HTML" toggle so users can set rich-text signatures and have them sent as HTML in outgoing mail, addressing issue thunderbird#8841. - Identity.signatureIsHtml persisted alongside the existing signature fields; LegacyAccountStorageHandler reads/writes/deletes the new key; IdentitySettingsDescriptions bumps to settings version 111. - Edit Identity and Account Composition defaults screens gain a "Format signature as HTML" checkbox. - TextBodyBuilder short-circuits HtmlConverter.textToHtmlFragment when the flag is set, and runs the signature through HtmlConverter.htmlToText for the plain-text message path. - HtmlSignatureSanitizer sanitizes user HTML via a Jsoup Safelist.relaxed baseline, stripping scripts, event handlers, and javascript: URLs. - MessageCompose renders the HTML signature in a MessageWebView preview instead of raw text, so drafts and new composes show the rendered result. Remote images and natural device-size rendering are enabled for the user's own signature content. - Draft reload looks up the matching identity by email via account.findIdentity() to preserve signatureIsHtml for multi-identity accounts, since the X-K9mail-Identity header does not encode the flag. - Tests: HtmlSignatureSanitizerTest (10 cases) and TextBodyBuilderHtmlSignatureTest (4 cases).
Contributor
|
Missing report label. Set exactly one of: |
Contributor
|
Thank you for this @joshua-grimmett - very cool stuff. |
Collaborator
|
hey @joshua-grimmett, we haven't forgotten about this and appreciate you doing this (especially since it's one of our main roadmap items this year). @rafaeltonholo was put on some last minute changes for our Thundermail project, but will be back on this in the next week or so. |
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.
Summary
Adds a per-identity "Format signature as HTML" toggle so users can write rich-text signatures and have them sent as HTML in outgoing mail. Refs #8841.
When the flag is on, the signature is embedded verbatim in outgoing HTML messages (no text-to-HTML conversion), converted via Jsoup for outgoing plain-text messages, and rendered as a live WebView preview in the compose screen so drafts and new composes show the rendered result instead of raw tags.
Scope (vs #8841)
In scope ✅
Stretch (not in this PR)
Out of scope per #8841
Changes
Identity.signatureIsHtml: Booleanadded, persisted viaLegacyAccountStorageHandlerunder keysignatureIsHtml.$ident.IdentitySettingsDescriptionsregisters the new setting at version 111.TextBodyBuilder.getSignatureHtml()short-circuitsHtmlConverter.textToHtmlFragment()when the flag is set. For plain-text messages,TextBodyBuilder.getSignature()runs the HTML signature throughHtmlConverter.htmlToText()to produce a plain-text fallback.HtmlSignatureSanitizerwrapsJsoup.clean()with aSafelist.relaxed()baseline that strips<script>, event handler attributes,javascript:URLs,<iframe>,<object>, and<embed>elements.MessageComposerenders the HTML signature in aMessageWebView(reusing the component already used for quoted HTML) instead of showing raw tags in the plainEditText. Remote images and natural device-size rendering are enabled since the signature is the user's own content.account.findIdentity(email)looks up the matching account identity and inherits itssignatureIsHtmlvalue, preserving the flag across drafts for multi-identity accounts.Tests
HtmlSignatureSanitizerTest— 10 cases covering sanitisation (preserves basic formatting, strips scripts/event handlers /javascript:URLs / iframes, passes plain text unchanged).TextBodyBuilderHtmlSignatureTest— 4 cases covering the HTML short-circuit in both the HTML and plain-text body paths.TextBodyBuilderTest,MessageBuilderTest,ReplyToPresenterTest,IdentityHeaderBuilderTestupdated for the newIdentityfield and continue to pass../gradlew spotlessCheck detektpass locally.Screenshots
Edit Identity screen — new HTML checkbox:
Compose screen — rendered HTML signature preview:
Test plan
<script>/onclick/javascript:URLsHtmlConverter.htmlToText()