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

Commit

Permalink
Better filter out non-words
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Nov 17, 2022
1 parent d498856 commit 7384ce4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions synapse/storage/databases/main/user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,10 +971,11 @@ def _parse_words_icu(search_term: str) -> List[str]:

result = search_term[i:j]

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

i = j
Expand Down

0 comments on commit 7384ce4

Please sign in to comment.