Skip to content

gh-152845: Keep EFS flag for a file loaded from the archive#152846

Open
danny0838 wants to merge 4 commits into
python:mainfrom
danny0838:gh-152845
Open

gh-152845: Keep EFS flag for a file loaded from the archive#152846
danny0838 wants to merge 4 commits into
python:mainfrom
danny0838:gh-152845

Conversation

@danny0838

@danny0838 danny0838 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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.

danny0838 added 3 commits July 2, 2026 11:42
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in Library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants