Issue #14160: TarFile.extractfile() failed to resolve symbolic links when

the links were not located in an archive subdirectory.
This commit is contained in:
Lars Gustäbel 2012-04-24 22:42:08 +02:00
parent 13c598b1d8
commit 231d474a7b
4 changed files with 7 additions and 1 deletions

View File

@ -2397,7 +2397,7 @@ class TarFile(object):
"""
if tarinfo.issym():
# Always search the entire archive.
linkname = os.path.dirname(tarinfo.name) + "/" + tarinfo.linkname
linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname)))
limit = None
else:
# Search the archive before the link, because a hard link is

View File

@ -154,6 +154,9 @@ class UstarReadTest(ReadTest):
def test_fileobj_symlink2(self):
self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype")
def test_issue14160(self):
self._test_fileobj_link("symtype2", "ustar/regtype")
class CommonReadTest(ReadTest):

Binary file not shown.

View File

@ -56,6 +56,9 @@ Core and Builtins
Library
-------
- Issue #14160: TarFile.extractfile() failed to resolve symbolic links when
the links were not located in an archive subdirectory.
- Issue #14638: pydoc now treats non-string __name__ values as if they
were missing, instead of raising an error.