From d2556bc718f1fd9c4e29b9f013d07fe9e568f807 Mon Sep 17 00:00:00 2001 From: booosy <104043001+booosy@users.noreply.github.com> Date: Wed, 24 Aug 2022 01:59:51 -0700 Subject: [PATCH] Make sure the user has actually input some token to search with when doing exact searching (#337) --- files/routes/search.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/routes/search.py b/files/routes/search.py index 410424e2b..e3d32ae3c 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -91,9 +91,9 @@ def searchposts(v): ) else: posts = posts.filter(Submission.author_id == author.id) - if 'exact' in criteria: + if 'exact' in criteria and 'full_text' in criteria: regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries" - if('title' in criteria): + if 'title' in criteria: words = [Submission.title.regexp_match(regex_str)] else: words = [or_(Submission.title.regexp_match(regex_str), Submission.body.regexp_match(regex_str))] @@ -210,7 +210,7 @@ def searchcomments(v): else: comments = comments.filter(Comment.author_id == author.id) - if 'exact' in criteria: + if 'exact' in criteria and 'full_text' in criteria: regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries" words = [Comment.body.regexp_match(regex_str)] comments = comments.filter(*words)