File tree Expand file tree Collapse file tree
backend/apps/datasource/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import os
55import traceback
66import uuid
7+ import re
78from io import StringIO
89from typing import List
910from urllib .parse import quote
@@ -567,7 +568,7 @@ def inner():
567568
568569 for sheet_info in import_req .sheets :
569570 sheet_name = sheet_info .sheetName
570- table_name = f"{ sheet_name } _{ hashlib .sha256 (uuid .uuid4 ().bytes ).hexdigest ()[:10 ]} "
571+ table_name = f"excel_ { filter_string ( sheet_name ) } _{ hashlib .sha256 (uuid .uuid4 ().bytes ).hexdigest ()[:10 ]} "
571572 fields = sheet_info .fields
572573
573574 field_mapping = {f .fieldName : f .fieldType for f in fields }
@@ -617,3 +618,9 @@ def inner():
617618 return {"filename" : import_req .filePath , "sheets" : results }
618619
619620 return await asyncio .to_thread (inner )
621+
622+
623+ # only allow chinese, a-z, A-Z, 0-9
624+ def filter_string (text ):
625+ pattern = r'[^\u4e00-\u9fa5a-zA-Z0-9]'
626+ return re .sub (pattern , '' , text )
You can’t perform that action at this time.
0 commit comments