Skip to content

Commit e71569a

Browse files
committed
linter
1 parent 3a129af commit e71569a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

dojo/tools/mayhem/parser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,20 @@ def clean_mayhem_title_text(text):
214214
if not text:
215215
return ""
216216

217-
# Remove links
218-
link_regex = r"\[([^\]]+)\]\(([^)]+)\)"
217+
# Remove links (and add limit to avoid catastrophic backtracking)
218+
link_regex = r"\[[^\]]{1,100}?\]\([^)]{1,200}?\)"
219219
text = re.sub(link_regex, "", text)
220220

221221
# Remove URL encoded characters
222222
url_encoding_regex = r"&#x\d+;"
223223
text = re.sub(url_encoding_regex, "", text)
224224

225225
# Remove single or double quotes
226-
text = text.replace('"', "").replace("'", "")
226+
quotes_regex = r"[\"']"
227+
text = re.sub(quotes_regex, "", text)
227228

228229
# Remove TDID
229-
tdid_regex = r"TDID-\d+\s-\s"
230+
tdid_regex = r"TDID-\d+\s*-\s*|TDID-\d+-"
230231
text = re.sub(tdid_regex, "", text)
231232

232233
return text.strip()

0 commit comments

Comments
 (0)