Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 7384ce4

Browse files
committed
Better filter out non-words
1 parent d498856 commit 7384ce4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

synapse/storage/databases/main/user_directory.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,11 @@ def _parse_words_icu(search_term: str) -> List[str]:
971971

972972
result = search_term[i:j]
973973

974-
# libicu considers spaces between words as words, but we don't want to include
975-
# those in results as they would result in syntax errors in SQL queries (e.g.
976-
# "foo bar" would result in the search query including "foo & & bar").
977-
if result != " ":
974+
# libicu considers spaces and punctuation between words as words, but we don't
975+
# want to include those in results as they would result in syntax errors in SQL
976+
# queries (e.g. "foo bar" would result in the search query including "foo & &
977+
# bar").
978+
if len(re.findall(r"([\w\-]+)", result, re.UNICODE)):
978979
results.append(result)
979980

980981
i = j

0 commit comments

Comments
 (0)