Browse Source

make sure we do not get backslashes into item paths

on windows, we also want slashes, not backslashes.
Thomas Waldmann 2 years ago
parent
commit
b7ce3b1156
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/borg/helpers/fs.py

+ 2 - 0
src/borg/helpers/fs.py

@@ -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)