Commit 1ef9eda7 authored by Lars Gustäbel's avatar Lars Gustäbel

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

when the links were not located in an archive subdirectory.
parent d11d0d63
...@@ -2496,7 +2496,7 @@ class TarFile(object): ...@@ -2496,7 +2496,7 @@ class TarFile(object):
""" """
if tarinfo.issym(): if tarinfo.issym():
# Always search the entire archive. # 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 limit = None
else: else:
# Search the archive before the link, because a hard link is # Search the archive before the link, because a hard link is
......
...@@ -166,6 +166,9 @@ class UstarReadTest(ReadTest): ...@@ -166,6 +166,9 @@ class UstarReadTest(ReadTest):
def test_fileobj_symlink2(self): def test_fileobj_symlink2(self):
self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype") self._test_fileobj_link("./ustar/linktest2/symtype", "ustar/linktest1/regtype")
def test_issue14160(self):
self._test_fileobj_link("symtype2", "ustar/regtype")
class CommonReadTest(ReadTest): class CommonReadTest(ReadTest):
......
This diff was suppressed by a .gitattributes entry.
...@@ -56,6 +56,9 @@ Core and Builtins ...@@ -56,6 +56,9 @@ Core and Builtins
Library 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 - Issue #14638: pydoc now treats non-string __name__ values as if they
were missing, instead of raising an error. were missing, instead of raising an error.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment