Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions LLM/src/st_rag_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def load_document(source_path, source_type="URL"):
# Load from local file in data folder
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Go up to LLM folder
data_dir = os.path.join(current_dir, "data")
full_path = os.path.join(data_dir, source_path)

# Normalize and validate that full_path stays within data_dir
full_path = os.path.normpath(os.path.join(data_dir, source_path))
if not full_path.startswith(os.path.abspath(data_dir) + os.sep):
raise ValueError("Access to files outside the data directory is not allowed.")
if not os.path.exists(full_path):
raise FileNotFoundError(f"File not found: {full_path}")

Expand Down
Loading