Escape word in term-bolding regex

Fixes #869
main
Ben Busby 2022-10-31 12:45:44 -06:00
parent 77884d05f2
commit 6696f2b12b
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1
1 changed files with 4 additions and 1 deletions

View File

@ -63,6 +63,9 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup:
if len(element) == len(target_word):
return
# Ensure target word is escaped for regex
target_word = re.escape(target_word)
if re.match('.*[@_!#$%^&*()<>?/\|}{~:].*', target_word) or (
element.parent and element.parent.name == 'style'):
return