Issue #14160: TarFile.extractfile() failed to resolve symbolic links when
the links were not located in an archive subdirectory.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index bd73965..02858ae 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2397,7 +2397,7 @@
"""
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