Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions handlers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def get(self, base36_id=None):

current_user_obj = self.get_current_user_object()
q = self.get_argument("q", "")

# Take care of an mysql specific case where prepending an @ to a token
# causes a query syntax error. Wrap any token like that in double
# quotes first.
# More info: @distance fulltext search proximity operator
# https://dev.mysql.com/doc/refman/8.4/en/fulltext-boolean.html
q = re.sub(r'(?<!")(\B@[\w\-]+)(?!")', r'"\1"', q)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done in lib.utilities.clean_search_term?


context = self.get_argument("context", "")
if context:
q = q + " " + context
Expand Down