Patrick Rathje
commited on
Commit
·
2f00c8f
1
Parent(s):
ea8e878
remove leading slashes
Browse files- filesystem_access.py +3 -0
filesystem_access.py
CHANGED
|
@@ -13,6 +13,9 @@ class FilesystemAccess:
|
|
| 13 |
raise ValueError("Root path must be an existing directory.")
|
| 14 |
|
| 15 |
def _resolve_path(self, path: str) -> Path:
|
|
|
|
|
|
|
|
|
|
| 16 |
full_path = (self.root / path).resolve()
|
| 17 |
if not str(full_path).startswith(str(self.root)):
|
| 18 |
raise PermissionError("Access outside root path is not allowed.")
|
|
|
|
| 13 |
raise ValueError("Root path must be an existing directory.")
|
| 14 |
|
| 15 |
def _resolve_path(self, path: str) -> Path:
|
| 16 |
+
if path.startswith("/"):
|
| 17 |
+
path = path[1:] # remove any leading slash
|
| 18 |
+
|
| 19 |
full_path = (self.root / path).resolve()
|
| 20 |
if not str(full_path).startswith(str(self.root)):
|
| 21 |
raise PermissionError("Access outside root path is not allowed.")
|