From 947c392f722b7aa97a82bf443de68681700997a6 Mon Sep 17 00:00:00 2001 From: Mmx233 Date: Wed, 3 Apr 2024 23:19:18 +0800 Subject: [PATCH] fix: manually check the docs' filename --- backend/apps/rag/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/apps/rag/main.py b/backend/apps/rag/main.py index 0555cc2c..e7433f64 100644 --- a/backend/apps/rag/main.py +++ b/backend/apps/rag/main.py @@ -8,7 +8,7 @@ from fastapi import ( Form, ) from fastapi.middleware.cors import CORSMiddleware -import os, shutil, logging +import os, shutil, logging, re from pathlib import Path from typing import List @@ -450,7 +450,7 @@ def store_doc( try: is_valid_filename = True unsanitized_filename = file.filename - if not unsanitized_filename.isascii(): + if re.search(r'[\\/:"\*\?<>|\n\t ]', unsanitized_filename) is not None: is_valid_filename = False unvalidated_file_path = f"{UPLOAD_DIR}/{unsanitized_filename}"