summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2020-06-22 13:57:33 +0200
committerDalf <alex@al-f.net>2020-06-22 13:57:33 +0200
commit4c7b7870044e17167e1f3025bc192a492b908be9 (patch)
tree9bd2d449679f5a5497ee9327a7fc539ad45b595a /searx/webapp.py
parentc83007a6bcd2a7f765e7655b91cc6714fbc4ab01 (diff)
downloadsearxng-4c7b7870044e17167e1f3025bc192a492b908be9.tar.gz
searxng-4c7b7870044e17167e1f3025bc192a492b908be9.zip
[mod] don't try to proxify data URL.
Previously only image/jpeg was not proxied. This commit don't proxify all MIME types starting with "image/". This is a quick fix for the PR #1985 : the google_image engine can returns some data URL.
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-xsearx/webapp.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 35495a0ff..e1b6bea1c 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -335,8 +335,15 @@ def image_proxify(url):
if not request.preferences.get_value('image_proxy'):
return url
- if url.startswith('data:image/jpeg;base64,'):
- return url
+ if url.startswith('data:image/'):
+ # 50 is an arbitrary number to get only the beginning of the image.
+ partial_base64 = url[len('data:image/'):50].split(';')
+ if len(partial_base64) == 2 \
+ and partial_base64[0] in ['gif', 'png', 'jpeg', 'pjpeg', 'webp', 'tiff', 'bmp']\
+ and partial_base64[1].startswith('base64,'):
+ return url
+ else:
+ return None
if settings.get('result_proxy'):
return proxify(url)