Skip to content

gh-153625: rewrite with original filename in append mode for zipfile#153626

Open
danny0838 wants to merge 7 commits into
python:mainfrom
danny0838:gh-153625
Open

gh-153625: rewrite with original filename in append mode for zipfile#153626
danny0838 wants to merge 7 commits into
python:mainfrom
danny0838:gh-153625

Conversation

@danny0838

@danny0838 danny0838 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Fix an issue that auto-sanitized filename corrupts a ZIP archive when rewritten to the central directory in append mode.

ZipInfo.orig_filename is now only set when read from an archive; otherwise it fallbacks to ZipInfo.filename. When writing, ZipInfo.orig_filename rather than ZipInfo.filename is used to ensure that the identical original filename is written back.

A setter of ZipInfo.orig_filename is provided for backword compatibility, although it is not mean to be modified. (Actually, most ZipInfo attributes should not be modified. Though I leave it to future when a breaking change is well-prepared.)

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.

1 participant