1
0
mirror of https://github.com/searx/searx synced 2024-11-22 01:45:21 +01:00

Fix quoting issue in search_operator plugin (#3479)

This commit is contained in:
Grant Lanham Jr 2023-04-05 03:28:58 -04:00 committed by GitHub
parent 48eb13cf4c
commit 75b859d2a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,7 +11,11 @@ default_on = False
def on_result(request, search, result): def on_result(request, search, result):
q = search.search_query.query q = search.search_query.query
qs = shlex.split(q) # WARN: shlex.quote is designed only for Unix shells and may be vulnerable
# to command injection on non-POSIX compliant shells (Windows)
# https://docs.python.org/3/library/shlex.html#shlex.quote
squote = shlex.quote(q)
qs = shlex.split(squote)
spitems = [x.lower() for x in qs if ' ' in x] spitems = [x.lower() for x in qs if ' ' in x]
mitems = [x.lower() for x in qs if x.startswith('-')] mitems = [x.lower() for x in qs if x.startswith('-')]
siteitems = [x.lower() for x in qs if x.startswith('site:')] siteitems = [x.lower() for x in qs if x.startswith('site:')]