From d8dcdc74556569675911c6827db420f559e4a72f Mon Sep 17 00:00:00 2001 From: DUO Labs Date: Wed, 27 Oct 2021 12:50:21 -0400 Subject: [PATCH] Skip bolding search terms that are not alphanumeric (#496) Fixes #494 --- app/utils/results.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/utils/results.py b/app/utils/results.py index 0c04b76..c239a28 100644 --- a/app/utils/results.py +++ b/app/utils/results.py @@ -52,6 +52,9 @@ def bold_search_terms(response: str, query: str) -> BeautifulSoup: 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',