gh-152845: Keep EFS flag for a file loaded from the archive#152846
Open
danny0838 wants to merge 4 commits into
Open
gh-152845: Keep EFS flag for a file loaded from the archive#152846danny0838 wants to merge 4 commits into
danny0838 wants to merge 4 commits into
Conversation
This is a regression introduced by pythongh-84353/pythongh-150091, where a file with ASCII filename and UTF-8 comment lost its EFS flag when the central directory was rewritten in append mode, causing an unexpected metadata change and rendering its comment at risk of mis-decoding. Introduce an internal `_metadata_encoding` attribute for `ZipInfo` to make sure that files read from an archive keep the original encoding and EFS flag, while any newly added file enforces EFS when having a non-ASCII filename or comment.
Allow `metadata_encoding` parameter in all modes, allowing proper decoding with a customized codec in 'a' mode. Ignore this parameter for 'w'/'x' modes.
Member
There was a problem hiding this comment.
This should be in Library.
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.
Introduce an internal
_metadata_encodingattribute forZipInfoto make sure that files read from an archive keep the original encoding and EFS flag, while any newly added file enforces EFS when having a non-ASCII filename or comment.zipfile#152845