Compare commits

...

2 Commits

Author SHA1 Message Date
raiot e5deab6fa2 feat: 上传文件时限制扩展名 2023-08-24 23:15:54 +08:00
raiot 0ee978ba4e feat: 避免段落空格影响检测结果 2023-08-24 20:06:54 +08:00
2 changed files with 2 additions and 1 deletions

View File

@ -12,4 +12,4 @@ class SpaceSeparatedField(forms.CharField):
class UploadForm(forms.Form):
attachments = MultiFileField(min_num=1, max_num=10, max_file_size=1024 * 1024 * 64,
attrs={'class': 'file-input is-primary'})
attrs={'class': 'file-input is-primary', 'accept': '.docx, .doc, .dot, .pptx, .ppt, .pdf, .xls'})

View File

@ -29,6 +29,7 @@ def docx_find(file_path: str, keyword_list: list) -> dict:
paragraph_keyword = []
for para in doc_text.split('\n'):
para = re.sub(r'\s+', '', para) # 删除段落中空格
this_para_keyword = [keyword for keyword in keyword_list if keyword in para] # 查找该段落中的敏感词
if this_para_keyword: