Skip to content

gh-154894: Reject duplicate unicode path extra fields in zipfile - #156641

Open
litvak-daniil wants to merge 1 commit into
python:mainfrom
litvak-daniil:fix/gh-154894-duplicate-unicode-path
Open

gh-154894: Reject duplicate unicode path extra fields in zipfile#156641
litvak-daniil wants to merge 1 commit into
python:mainfrom
litvak-daniil:fix/gh-154894-duplicate-unicode-path

Conversation

@litvak-daniil

@litvak-daniil litvak-daniil commented Aug 30, 2026

Copy link
Copy Markdown

A member may carry the Unicode Path extra field (0x7075) more than once.
zipfile silently takes the last one, and other ZIP parsers make different
choices, so the decoded filename is ambiguous rather than merely redundant —
which is the differential described in the issue.

This raises BadZipFile when a second 0x7075 field is seen for the same
member. The reproducer from the issue now fails to open instead of returning
['last.txt'].

test_zipfile, test_zipimport and test_importlib pass.

Please note this is a behaviour change: archives that previously opened will
now be rejected. The issue is filed as "consider rejecting" and I did not find
a maintainer decision on it, so please treat this as a proposal. I am happy to
close it, or to emit a warning and keep the current last-one-wins behaviour
instead, if either is preferred.

@python-cla-bot

python-cla-bot Bot commented Aug 30, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

A member may carry the Unicode Path extra field (0x7075) more than once, and
ZIP parsers disagree on which duplicate wins, so the encoded filename is
ambiguous rather than merely redundant. zipfile silently took the last one.
Raise BadZipFile instead.
@litvak-daniil
litvak-daniil force-pushed the fix/gh-154894-duplicate-unicode-path branch from 4fee4db to 782d701 Compare August 30, 2026 10:10
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