Repository navigation
Fix thread decode errors - #145
Open
The-Compiler wants to merge 2 commits into
Open
The-Compiler wants to merge 2 commits into
The-Compiler wants to merge 2 commits into
Conversation
I got a mail which has `Content-Type: text/plain` with no `charset`, and hence should be US-ASCII: https://www.rfc-editor.org/info/rfc2045/#section-5.2 However, the mail contains German umlauts encoded as ISO-8859-1 (e.g. ü as =FC in quoted-printable). Despite `man notmuch-show` claiming: The JSON output is always encoded as UTF-8 and any message content included in the output will be charset-converted to UTF-8. the output as shown by notmuch show --format=json mid:6A79497BAB764AB38C7F0BA1607B46BF@ad.ugs.net *does* contain a literal e.g. 0xFC byte in place of the ü. Passing binary data to Python's json.loads does not help, because it still expects one of UTF-{8,16,32} as per the JSON standard. Instead of crashing, use errors="replace", which instead replaces the problematic bytes with � (U+FFFD, REPLACEMENT CHARACTER). It's somewhat questionable to do this for machine-parsed output (as it's technically silent data corruption). However, e.g. attachments take a different code path and we assume "raw" data fields to be correct notmuch output. Thus, this should only ever reach the message text as shown to the user, where this seems the correct strategy.
Before, we opened an empty (no subject) panel when refreshing failed. Instead, refuse to open a panel.
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.
I got a mail which has
Content-Type: text/plainwith nocharset, and hence should be US-ASCII: https://www.rfc-editor.org/info/rfc2045/#section-5.2However, the mail contains German umlauts encoded as ISO-8859-1 (e.g. ü as
=FCin quoted-printable). Despiteman notmuch-showclaiming:the output as shown by
does contain a literal e.g.
0xFCbyte in place of the ü.Passing binary data to Python's
json.loadsdoes not help, because it still expects one of UTF-{8,16,32} as per the JSON standard.Instead of crashing, use
errors="replace", which instead replaces the problematic bytes with � (U+FFFD, REPLACEMENT CHARACTER). It's somewhat questionable to do this for machine-parsed output (as it's technically silent data corruption). However, e.g. attachments take a different code path and we assume "raw" data fields to be correct notmuch output. Thus, this should only ever reach the message text as shown to the user, where this seems the correct strategy.As a drive-by fix, handle refresh errors more gracefully: Before, we opened an empty (no subject) panel when refreshing failed. Instead, refuse to open a panel.