From 0dfa4525fa7ca9ca1544830fdc5823ca4a16b1d5 Mon Sep 17 00:00:00 2001 From: TLSM Date: Sun, 2 Oct 2022 07:42:42 -0400 Subject: [PATCH] Remove special characters from search query. --- files/routes/search.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/routes/search.py b/files/routes/search.py index c96925feb..abba33961 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -207,8 +207,9 @@ def searchcomments(v): else: comments = comments.filter(Comment.author_id == author.id) if 'q' in criteria: + tokens = map(lambda x: re.sub(r'[\0():|&*!]', '', x), criteria['q']) comments = comments.filter(Comment.body_ts.match( - ' & '.join(criteria['q']), + ' & '.join(tokens), postgresql_regconfig='english')) if 'over18' in criteria: comments = comments.filter(Comment.over_18 == True)