mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
gh-91387: Strip trailing slash from tarfile longname directories (GH-32423)
Co-authored-by: Brett Cannon <brett@python.org>
(cherry picked from commit c1e19421c2
)
Co-authored-by: Chris Fernald <chrisf671@gmail.com>
This commit is contained in:
parent
cc42716275
commit
f6d777ce38
3 changed files with 28 additions and 0 deletions
|
@ -1163,6 +1163,11 @@ class TarInfo(object):
|
|||
# header information.
|
||||
self._apply_pax_info(tarfile.pax_headers, tarfile.encoding, tarfile.errors)
|
||||
|
||||
# Remove redundant slashes from directories. This is to be consistent
|
||||
# with frombuf().
|
||||
if self.isdir():
|
||||
self.name = self.name.rstrip("/")
|
||||
|
||||
return self
|
||||
|
||||
def _proc_gnulong(self, tarfile):
|
||||
|
@ -1185,6 +1190,11 @@ class TarInfo(object):
|
|||
elif self.type == GNUTYPE_LONGLINK:
|
||||
next.linkname = nts(buf, tarfile.encoding, tarfile.errors)
|
||||
|
||||
# Remove redundant slashes from directories. This is to be consistent
|
||||
# with frombuf().
|
||||
if next.isdir():
|
||||
next.name = next.name.removesuffix("/")
|
||||
|
||||
return next
|
||||
|
||||
def _proc_sparse(self, tarfile):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue