Fix UTF-8 header corruption when fallback charset differs#10078
Open
OctopusET wants to merge 1 commit intoroundcube:masterfrom
Open
Fix UTF-8 header corruption when fallback charset differs#10078OctopusET wants to merge 1 commit intoroundcube:masterfrom
OctopusET wants to merge 1 commit intoroundcube:masterfrom
Conversation
Add UTF-8 detection before charset conversion to prevent double-encoding of raw UTF-8 headers (e.g., Korean from Outlook).
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
Korean email subjects display as garbled text (
í¬ìФí¬ì˜¬instead of포스포올) when:charset=ISO-8859-1)Root Cause
In
rcube_mime::decode_mime_string(), non-MIME headers use the body's charset as fallback. UTF-8 bytes get misinterpreted as Latin-1 and double-encoded.Solution
Add UTF-8 detection before fallback conversion:
This validates UTF-8 byte sequences before applying potentially wrong charset conversion. Random Latin-1 bytes have only ~1/15 chance of forming valid UTF-8 sequences.
Standards
RFC 6532 (2012) legitimizes raw UTF-8 in email headers via SMTPUTF8 extension.
References
IsUTF8()- validates UTF-8 before falling back to other encodingsmozilla::EncodingDetector- unified charset detectionCharsetDetector- checks byte sequences for legal UTF-8 patternsnsUTF8Prober- Mozilla-derived UTF-8 state machine proberScreenshots
Before
After