1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-22 20:17:45 +01:00

Merge pull request #2565 from dalf/upd-wikipedia

[upd] wikipedia engine: return an empty result on query with illegal characters
This commit is contained in:
Alexandre Flament 2021-02-12 10:57:05 +01:00 committed by GitHub
commit 7dcf67a47a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,17 @@ def request(query, params):
def response(resp): def response(resp):
if resp.status_code == 404: if resp.status_code == 404:
return [] return []
if resp.status_code == 400:
try:
api_result = loads(resp.text)
except:
pass
else:
if api_result['type'] == 'https://mediawiki.org/wiki/HyperSwitch/errors/bad_request' \
and api_result['detail'] == 'title-invalid-characters':
return []
raise_for_httperror(resp) raise_for_httperror(resp)
results = [] results = []