Skip to content

Commit f190606

Browse files
fix
1 parent b4a0740 commit f190606

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/gitingest/query_parser.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import os
56
import re
67
import uuid
78
import warnings
@@ -326,11 +327,17 @@ def _parse_local_dir_path(path_str: str) -> IngestionQuery:
326327
IngestionQuery
327328
A dictionary containing the parsed details of the file path.
328329
330+
Raises
331+
------
332+
InvalidPatternError
333+
If the path escapes the allowed root directory.
334+
329335
"""
330336
root_path = TMP_BASE_PATH.resolve()
331337
path_obj = Path(path_str).resolve()
332338
if os.path.commonpath([root_path, path_obj]) != str(root_path):
333-
raise InvalidPatternError(f"Path {path_str} escapes the allowed root directory.")
339+
msg = f"Path {path_str} escapes the allowed root directory."
340+
raise InvalidPatternError(msg)
334341
slug = path_obj.name if path_str == "." else path_str.strip("/")
335342
return IngestionQuery(local_path=path_obj, slug=slug, id=str(uuid.uuid4()))
336343

0 commit comments

Comments
 (0)