Repository navigation
Conversation
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.
Binary
read_po()starts decoding with UTF-8 and only applies the catalog's declared charset after parsing the header entry. A non-UTF8 translator comment or metadata value before Content-Type therefore raises UnicodeDecodeError before the declaration can take effect.Babel can produce the input itself:
The same problem occurs with Vim's French catalog, which declares ISO-8859-15 and has non-ASCII translator comments before its header.
Buffer the first binary header entry, read its declared charset, then replay the original lines through the existing parser. Text streams and explicit charset calls keep their current behavior. The scan stops at the first entry and does not search translated message text for a charset. Placeholder CHARSET, unknown-codec errors, single-use iterators and existing malformed-header errors are covered.
Validation:
This was found during a real-catalog roundtrip investigation. The fix and tests were prepared with AI assistance and executed locally. The independent MO metadata fix in #1375 is outside this patch.