Repository navigation
Conversation
Since 0.10.0 every read goes through readCompleteRawMessage before
Thunderbird parses the message. Four things broke that for add-on
providers such as Owl (Exchange/Office 365):
- Only IMAP messages were streamed from the server when no complete
local copy exists. An Owl message that was never opened in Thunderbird
has no offline copy, and the read failed ("Failed to get message",
"Failed to read message for display") even with encrypted-message
access enabled. Treat every non-local server type the way IMAP is
treated: the Offline flag marks a complete local copy, otherwise the
message service streams it. Owl maintains the same flag and offline
store. An empty server type stays local-only.
- The local copy was opened with getMsgInputStream, which reads the
store from the message's offset until it recognises the next
separator. Owl writes "From - <date>" plus X-Mozilla-* headers in
front of every message it caches, the store escapes that line to
">From ", and the mbox reader does not accept such a line as the start
of a header block, so the read ran on into the following messages
(observed: a 14 KB message read back as 50 KB holding three messages,
bounded only by the server-reported size). That snapshot fails every
gate, and rawSource returned other messages' content. Open the stored
copy through getLocalMsgStream (Thunderbird 145+, bug 1968399), which
is bounded to the message and which providers implement with their
own slice; keep getMsgInputStream for older builds.
- The ">From - <date>" envelope line itself made the strict raw gate
reject every cached Owl message as "encryption status could not be
determined" while the opt-in was off, with the subject shown as
"[Encrypted message]". libmime skips such a line (mimehdrs.cpp, the BSD
mailbox delimiter hack). Drop a leading envelope line from local and
streamed copies before classification; rawSource no longer carries it
either. A header field name cannot contain a space, so the pattern
never matches header text.
- Owl records offlineMessageSize before the store escapes that line, so
its bounded slice ends one byte short, inside the final CRLF (every
cached copy checked ended in "--\r"). A lone CR fails both gates, but
a bare CR at the very end has nothing after it to hide: complete it to
CRLF. A bare CR anywhere else is still withheld.
LOCAL_SERVER_TYPES moves next to the raw readers so both callers share
it.
…cted content Thunderbird's native Microsoft Graph accounts (server type "graph") do not download a message body until it is displayed. With the previous commit such messages are now streamed through the folder's message service, like IMAP and Owl. When that download still fails (offline, server error, or a message service that refuses), two misleading errors remained: - getMessage returned the generic "Failed to get message" / "Failed to read raw source". - replyToMessage with saveAsDraft mapped every failed preflight read to "Automatic drafting of encrypted messages is blocked, including protected or unknown MIME content", although nothing had been read or classified. readCompleteRawMessage now marks a failed server fetch (non-success stop status, or a synchronous failure to look up or start the message service) as isBodyUnavailable. getMessage reports it as "Message body is not available offline and could not be downloaded from the server". The direct-send preflight returns a matching refusal, and saveAsDraft distinguishes three cases: content that was read and is protected or unknown (unchanged encryption error), an original that could not be retrieved within the drafting limits, and a body that could not be downloaded. All three still refuse; only the wording changes. Encrypted and signed originals are still classified from the raw bytes before Gloda runs and are still blocked. Tests cover undownloaded Graph messages for getMessage, rawSource, saveAsDraft and direct reply, including an encrypted server copy and both kinds of fetch failure, and check that a local folder still never downloads. Fixes TKasperczyk#265 Fixes TKasperczyk#275 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…throws Thunderbird 128 and 140 ESR (the extension's minimum is 128) declare nsIMsgFolder.getLocalMsgStream on every folder, but the nsMsgDBFolder base implementation returns NS_ERROR_NOT_IMPLEMENTED. The typeof check added for add-on providers is true there, so a folder class that does not override it would fail every stored-message read instead of using getMsgInputStream as before. Fall back to getMsgInputStream when getLocalMsgStream throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DIRECT_SEND_RAW_ERROR covers any read failure that is not a failed download, including an unreadable local store, so the saveAsDraft message no longer claims the original was too large or too slow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sjmurdoch
marked this pull request as ready for review
November 25, 2026 14:55
This branch has not been deployed
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.
Problem
On Thunderbird's native Microsoft Graph accounts (server type
graph, folder URIsgraph://…), Thunderbird doesn't download a message body until the message is displayed, and the Offline flag stays clear until then. Since 0.10.0 every read first goes throughreadCompleteRawMessage, which streams a message from the server only forimap. Every other server type falls back to the local store, which is empty for these messages. So for any Graph message that hasn't been opened in Thunderbird:getMessagereturnsFailed to get message(orFailed to read raw sourcewithrawSource). Reported in getMessage fails with "Failed to get message" on Microsoft Graph accounts when the message has no offline copy #265 and getMessage fails with "Failed to get message" on Microsoft Graph (graph://) accounts #275.replyToMessagewithsaveAsDraft: truefails the same raw read in the direct-send preflight. That failure is then reported as "Automatic drafting of encrypted messages is blocked, including protected or unknown MIME content", even though nothing was read or classified.Both errors come from the same missing-body path.
Changes
Includes fix(messages): read add-on provider (Owl/Exchange) messages through the raw gate #262 unchanged (commit by @andrei-rizoiu, author preserved). Every non-local server type is treated the way IMAP is: the Offline flag marks a complete local copy, and otherwise the message is streamed through the folder's own message service (
streamMessage). This covers Graph as well as Owl/EWS, with no scheme-specific code. If fix(messages): read add-on provider (Owl/Exchange) messages through the raw gate #262 is merged first, this PR reduces to the three commits after it.Clear errors when the body still can't be fetched. A failed server fetch (non-success stop status, or the message service failing synchronously) is marked
isBodyUnavailableinreadCompleteRawMessage.getMessagereturnsMessage body is not available offline and could not be downloaded from the server.saveAsDraftnow tells apart content that was read and is protected or unknown (the existing encryption error, unchanged), an original that couldn't be retrieved within the drafting limits, and a body that couldn't be downloaded.Fallback for Thunderbird 128/140 in fix(messages): read add-on provider (Owl/Exchange) messages through the raw gate #262's stream opener. In ESR 128 and 140, the
nsMsgDBFolderbase implementation ofgetLocalMsgStreamreturnsNS_ERROR_NOT_IMPLEMENTED, but thetypeofcheck still passes. A throw now falls back togetMsgInputStream. The comment in fix(messages): read add-on provider (Owl/Exchange) messages through the raw gate #262 also cites bug 1968399 for the 145+ change, but that bug is an unrelated GeckoView one, so the reference probably needs correcting.All three error cases in change 2 still refuse; only the wording changes. Originals are still classified from their raw bytes before Gloda runs: encrypted ones are still blocked, and clear-signed ones are handled as on v0.10.0.
Testing
npm test: all tests pass, plus 12 new ones intest/privacy-messages.test.cjs("undownloaded Microsoft Graph messages"). They covergetMessage(body andrawSource) on an undownloaded Graph message, an already-downloaded one, both kinds of fetch failure (forgetMessage,saveAsDraftand direct reply), a successful draft from a server-streamed copy, an encrypted server copy that is still blocked, and a local folder that never downloads. 10 of them fail on v0.10.0, and 6 still fail with fix(messages): read add-on provider (Owl/Exchange) messages through the raw gate #262 alone. A further test covers thegetLocalMsgStreamfallback.message-headers.test.cjs, "collects all fresh handles before resuming lookup-without-direct") hit its 15 s timeout in 1 of 3 full-suite runs. It passes in isolation with and without this change, and the code it covers isn't touched here.npx eslint .: no errors (the 5 warnings already onmainare unchanged).getMessagereturned the body for all 12 unread Inbox messages (about 0.3 s each). None of them were marked read.saveAttachments: truesaved 3 PDF attachments at their declared sizes.replyToMessagewithsaveAsDraft: truesaved a threaded, quoted draft in Drafts (Re:subject,In-Reply-To/References, cited body). This held both for an Inbox message and for a 2014 list message that had never been fetched. Thunderbird 160 then shows "FCC copy failed", which is bug 2092297, fixed for 162: the draft is created on the server and then moved into the folder it is already in.deleteMessagesmoved the test drafts to Deleted Items.multipart/encryptedoriginals: still refused bysaveAsDraft, and still withheld bygetMessage.getMessage(body andrawSource) returned "Message body is not available offline and could not be downloaded from the server", andsaveAsDraftreturned the matching drafting error. All three came back at once, with no hang. A Graph message downloaded earlier still read normally while offline.Fixes #265
Fixes #275
Builds on #262
🤖 Generated with Claude Code