Skip bolding search terms that are not alphanumeric (#496)

Fixes #494
main
DUO Labs 2021-10-27 12:50:21 -04:00 committed by GitHub
parent 1abd040428
commit d8dcdc7455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -52,6 +52,9 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup:
if len(element) == len(target_word): if len(element) == len(target_word):
return return
if not target_word.isalnum():
return
element.replace_with( element.replace_with(
re.sub(fr'\b((?![{{}}<>-]){target_word}(?![{{}}<>-]))\b', re.sub(fr'\b((?![{{}}<>-]){target_word}(?![{{}}<>-]))\b',
r'<b>\1</b>', r'<b>\1</b>',