Skip to content

gh-149980: Strip all trailing slashes from GNU long directory names i…#150019

Merged
encukou merged 1 commit into
python:mainfrom
ankhikarmakar:fix-149980-tarfile-gnulong-rstrip
May 18, 2026
Merged

gh-149980: Strip all trailing slashes from GNU long directory names i…#150019
encukou merged 1 commit into
python:mainfrom
ankhikarmakar:fix-149980-tarfile-gnulong-rstrip

Conversation

@ankhikarmakar
Copy link
Copy Markdown
Contributor

Title:
gh-149980: Strip all trailing slashes from GNU long directory names in tarfile

Body:
In tarfile._proc_gnulong, GNU long-name directory entries had only a single
trailing slash removed (removesuffix("/")), while short-name directories and
PAX entries have all trailing slashes stripped (rstrip("/") in _frombuf /
_proc_builtin). This made a foo/// directory show up as foo via the
short path and foo// via the GNU long-name path.

This PR aligns _proc_gnulong with the other paths by using rstrip("/"), and
adds a regression test that writes a GNU-format archive containing both a short
and a long directory name ending in /// and asserts the parsed names match.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented May 18, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@encukou encukou enabled auto-merge (squash) May 18, 2026 19:13
@encukou encukou merged commit 5775aa8 into python:main May 18, 2026
57 checks passed
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.

2 participants