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
Member
|
I tried to avoid adding new attributes. Let's see how we can solve this. |
Contributor
Author
|
I agree that we should take care about new attributes. However it seems to be the most elegant way to handle the "preserve the original encoding only for files read from the archive" issue. Additionally it also works when someone tries to replicate a file by copying the ZipInfo object. |
Fix a regression introduced by pythongh-84353/pythongh-150091 where the EFS flag was dropped or omitted when a file with an ASCII filename and a UTF-8 comment was written to an archive. This affected both newly added files and existing files rewritten to the central directory in append mode, causing an unexpected metadata change and leading to comment mis-decoding. Introduce an internal `_metadata_encoding` attribute for `ZipInfo` to ensure that files read from an archive preserve their original encoding and EFS flags, while newly added files now properly enforce EFS if they contain a non-ASCII filename or comment.
Allow the `metadata_encoding` parameter in all modes, enabling proper decoding with a customized codec in 'a' mode. This parameter is ignored for 'w' and 'x' modes.
Member
|
@danny0838, please never use amend and force-push, at least after the start of review. It forces reviewers to start review from start instead of just looking at new changes. |
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