1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-01 12:45:34 +00:00

make sure we do not get backslashes into item paths

on windows, we also want slashes, not backslashes.
This commit is contained in:
Thomas Waldmann 2023-06-10 12:52:00 +02:00
parent db96c0c487
commit b7ce3b1156
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -229,6 +229,8 @@ def make_path_safe(path):
`path` contain any '..' elements.
"""
path = path.lstrip("/")
if "\\" in path: # borg always wants slashes, never backslashes.
raise ValueError(f"unexpected backslash(es) in path {path!r}")
if path.startswith("../") or "/../" in path or path.endswith("/..") or path == "..":
raise ValueError(f"unexpected '..' element in path {path!r}")
path = os.path.normpath(path)