mirror of
https://github.com/searx/searx
synced 2024-12-11 11:40:36 +01:00
[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.
This commit is contained in:
parent
c83007a6bc
commit
4c7b787004
@ -335,8 +335,15 @@ def image_proxify(url):
|
|||||||
if not request.preferences.get_value('image_proxy'):
|
if not request.preferences.get_value('image_proxy'):
|
||||||
return url
|
return url
|
||||||
|
|
||||||
if url.startswith('data:image/jpeg;base64,'):
|
if url.startswith('data:image/'):
|
||||||
return url
|
# 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'):
|
if settings.get('result_proxy'):
|
||||||
return proxify(url)
|
return proxify(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user