DeprecationWarning, 2)
return stat.filemode(mode)
+def contains_dot_dot(name):
+ """Check whether a path contains double dots thus referring to the parent
+ directory.
+ """
+ l = len(name)
+ if l < 2:
+ return False
+ p = 0
+ while True:
+ if name[p] == '.' and name[p + 1] == '.':
+ ppp = p + 2
+ if ppp == l or name[ppp] == '/':
+ return True
+ while name[p] != '/':
+ if p == l - 2:
+ return False
+ p += 1
+ if p == l - 2:
+ break
+ p += 1
+ return False
+
class TarError(Exception):
"""Base exception."""
pass
if tarinfo.islnk():
tarinfo._link_target = os.path.join(path, tarinfo.linkname)
- if symlink_cb is not None and tarinfo.issym():
+ if symlink_cb is not None and tarinfo.issym() \
+ and (os.path.isabs(tarinfo.linkname)
+ or contains_dot_dot(tarinfo.linkname)):
return symlink_cb(tarinfo, path, set_attrs)
try: