Skip to content

Commit fcdd5fd

Browse files
committed
bugfix: Added timeout to mitigate ReDoS issue
1 parent 56fc993 commit fcdd5fd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

modules/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
import csv
1010
import threading
1111
import requests
12-
import re
1312
import hmac
1413
import html
1514
import hashlib
1615

1716
import gradio as gr
17+
import regex as re
1818
import getpass
1919
from pypinyin import lazy_pinyin
2020
import tiktoken
@@ -511,7 +511,7 @@ def init_history_list(user_name="", prepend=None):
511511
def filter_history(user_name, keyword):
512512
history_names = get_history_names(user_name)
513513
try:
514-
history_names = [name for name in history_names if re.search(keyword, name)]
514+
history_names = [name for name in history_names if re.search(keyword, name, timeout=0.01)]
515515
return gr.update(choices=history_names)
516516
except:
517517
return gr.update(choices=history_names)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ Pillow>=10.1.0
4141
protobuf==3.20.3
4242
ollama>=0.1.6
4343
numexpr
44+
regex

0 commit comments

Comments
 (0)