Skip to content

gh-127636: Fix tarfile extracting trailing slash member names - #152984

Merged
gpshead merged 7 commits into
python:mainfrom
yuanx749:tar-slash
Sep 8, 2026
Merged

gh-127636: Fix tarfile extracting trailing slash member names#152984
gpshead merged 7 commits into
python:mainfrom
yuanx749:tar-slash

Conversation

@yuanx749

@yuanx749 yuanx749 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #127636.

Member lookup now tries the exact archive name first and retains the trailing-slash-stripped lookup as a fallback. This allows names returned by getnames() to be passed to extract() while keeping the previous fallback.

@python-cla-bot

python-cla-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@gpshead gpshead self-assigned this Sep 8, 2026
Note that './mydir/' is a regular-file member, not DIRTYPE, so a future
reader does not turn it into a directory and lose the regression
coverage.  Also assert the member actually extracts as a file rather
than only checking that extract() does not raise.
@gpshead gpshead added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 8, 2026
@gpshead
gpshead enabled auto-merge (squash) September 8, 2026 04:01
@gpshead
gpshead merged commit 7a562c4 into python:main Sep 8, 2026
104 of 106 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @yuanx749 for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

GH-157167 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 8, 2026
@bedevere-app

bedevere-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

GH-157168 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 8, 2026
@bedevere-app

bedevere-app Bot commented Sep 8, 2026

Copy link
Copy Markdown

GH-157169 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 8, 2026
@yuanx749
yuanx749 deleted the tar-slash branch September 8, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python3.9+ throws KeyError when extracting folder with trailing slash

2 participants