fix(mail): improve Japanese charset decoding reliability on Android#10883
Open
kaberingo wants to merge 1 commit intothunderbird:mainfrom
Open
fix(mail): improve Japanese charset decoding reliability on Android#10883kaberingo wants to merge 1 commit intothunderbird:mainfrom
kaberingo wants to merge 1 commit intothunderbird:mainfrom
Conversation
- Normalize Shift-JIS aliases (shift-jis, sjis, ms932, windows-31j, x-sjis, x-ms-cp932) to shift_jis for consistent handling - Add EUC-JP fallback aliases (x-euc-jp, euc_jp) to the charset fallback map - Always use Iso2022JpToShiftJisInputStream for iso-2022-jp decoding to bypass Android ICU4J's unreliable QP-decoded byte sequence handling, which could cause ESC bytes and "$B"/"(B" escape remnants to appear as literal text - Auto-detect ISO-2022-JP when Content-Type has no charset parameter by scanning for ESC$B / ESC$@ escape sequences, fixing garbled output from Japanese feature phones and carrier webmail that omit the charset header - Implement getAddressFromReceivedHeader() in JisSupport to properly extract addresses from the "for" clause of Received headers (both angle-bracket and bare address forms), enabling correct JIS variant detection Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Missing report label. Set exactly one of: |
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
This PR improves Japanese email rendering on Android by fixing several
charset handling issues in
CharsetSupportandJisSupport.Changes
CharsetSupport
shift-jis,sjis,ms932,windows-31j,x-sjis,x-ms-cp932) toshift_jisx-euc-jp,euc_jp) to the charsetfallback map
iso-2022-jpthroughIso2022JpToShiftJisInputStreaminstead of relying on Android's ICU4J decoder, which silently
mishandles QP-decoded byte sequences and causes ESC bytes or
$B/(Bescape remnants to appear as literal text
Content-Typehas nocharsetparameterby scanning for
ESC$B/ESC$@escape sequences — Japanese featurephones and carrier webmail systems commonly omit the charset header,
causing garbled output (e.g.
$BJIC...) when decoded as US-ASCIIJisSupport
getAddressFromReceivedHeader()(was a no-op stub) tocorrectly parse the recipient address from the
forclause ofReceivedheaders, enabling proper JIS variant detection for DoCoMo,SoftBank, and KDDI carrier mail
Testing
Unit tests added/updated for all new logic:
CharsetSupportTest: Shift-JIS alias normalization, EUC-JP aliasfallback,
hasIso2022JpEscapeSequence()edge casesMessageExtractorTest: QP-encoded ISO-2022-JP with/without charsetheader, multi-line bodies, raw 7-bit bodies
JisSupportTest(new): carrier address detection viaFromandReceivedheaders, iPhone mailer detection