Skip to content

bpo-21987: fix TarFile.getmember getting a dir with a trailing slash #30283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

akulakov
Copy link
Contributor

@akulakov akulakov commented Dec 28, 2021

https://bugs.python.org/issue21987

Co-authored with Matt Behrens

self.add_dir_and_getmember('a'*101)

def add_dir_and_getmember(self, name):
tar = tarfile.open(tmpname, 'w')
Copy link
Member

Choose a reason for hiding this comment

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

Use context managers.

You can use temp_cwd() and temp_dir() from test.support.os_helper for creating temporary dirs.

Comment on lines 237 to 238
tar.getmember(name)
tar.getmember(name + '/')
Copy link
Member

Choose a reason for hiding this comment

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

Maybe test that these two return the same info.

@miss-islington
Copy link
Contributor

Thanks @akulakov for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9, 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 21, 2022
…ythonGH-30283)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
@bedevere-bot
Copy link

GH-30737 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jan 21, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 21, 2022
…ythonGH-30283)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
@bedevere-bot
Copy link

GH-30738 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Jan 21, 2022
miss-islington added a commit that referenced this pull request Jan 21, 2022
…H-30283)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
@akulakov akulakov deleted the 21987-Fix-tarfile-getmember-trailing-slash branch January 21, 2022 12:45
@akulakov
Copy link
Contributor Author

akulakov commented Jan 21, 2022

Serhiy and Jelle, thanks for reviewing!

serhiy-storchaka pushed a commit that referenced this pull request Jan 23, 2022
…slash (GH-30283) (GH-30738)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
hello-adam pushed a commit to hello-adam/cpython that referenced this pull request Jun 2, 2022
…slash (pythonGH-30283) (pythonGH-30738)

(cherry picked from commit cfadcc3)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
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.

6 participants