on master help sign in
[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.

commit4c7b7870044e17167e1f3025bc192a492b908be9 authorDalf <alex@al-f.net> dateMon 22 Jun 2020, 13:57 (6 years ago) parentc83007a
1 file changed+9−2
searx/webapp.py+9−2
searx/webapp.py+9−2
@@ -335,8 +335,15 @@ def image_proxify(url):
335335 if not request.preferences.get_value('image_proxy'):
336336 return url
337337
338− if url.startswith('data:image/jpeg;base64,'):
339− return url
338+ if url.startswith('data:image/'):
339+ # 50 is an arbitrary number to get only the beginning of the image.
340+ partial_base64 = url[len('data:image/'):50].split(';')
341+ if len(partial_base64) == 2 \
342+ and partial_base64[0] in ['gif', 'png', 'jpeg', 'pjpeg', 'webp', 'tiff', 'bmp']\
343+ and partial_base64[1].startswith('base64,'):
344+ return url
345+ else:
346+ return None
340347
341348 if settings.get('result_proxy'):
342349 return proxify(url)