summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-02-12 10:57:05 +0100
committerGitHub <noreply@github.com>2021-02-12 10:57:05 +0100
commit7dcf67a47afd4a63b62d052b9db51ec8a9c7b40c (patch)
tree96e63abbeee677329396d69204e1d44ed74192c8 /searx
parent2b60d0d243f5f5848c44ffc4d8503ee974fc614b (diff)
parent7d6e69e2f9c1efd76616af0f58d0d7313a338c47 (diff)
downloadsearxng-7dcf67a47afd4a63b62d052b9db51ec8a9c7b40c.tar.gz
searxng-7dcf67a47afd4a63b62d052b9db51ec8a9c7b40c.zip
Merge pull request #2565 from dalf/upd-wikipedia
[upd] wikipedia engine: return an empty result on query with illegal characters
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/wikipedia.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py
index c8e589e64..2adfefa69 100644
--- a/searx/engines/wikipedia.py
+++ b/searx/engines/wikipedia.py
@@ -56,6 +56,17 @@ def request(query, params):
def response(resp):
if resp.status_code == 404:
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)
results = []