mirror of
https://github.com/searx/searx
synced 2025-08-30 14:08:47 +00:00
[upd] wikipedia engine: return an empty result on query with illegal characters
on some queries (like an IT error message), wikipedia returns an HTTP error 400. this commit returns an empty result instead of showing an error to the user.
This commit is contained in:
@@ -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 = []
|
||||||
|
Reference in New Issue
Block a user