From 4e91a02a3ecbaaf851dba64a89064c3c49765706 Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Wed, 27 Oct 2021 07:35:33 -0400 Subject: [PATCH] Ignore target_words that are not alphanumeric --- app/utils/results.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/utils/results.py b/app/utils/results.py index 0c04b76..61bde1c 100644 --- a/app/utils/results.py +++ b/app/utils/results.py @@ -51,7 +51,10 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup: # the replacement if len(element) == len(target_word): return - + + if not target_word.isalnum(): + return + element.replace_with( re.sub(fr'\b((?![{{}}<>-]){target_word}(?![{{}}<>-]))\b', r'\1',