diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2020-06-24 17:13:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-24 17:13:03 +0000 |
| commit | ccb1fe11d7d728ab00d32f7626f8f8321befe2ea (patch) | |
| tree | a9b8ad94dfbc8b8272bbe7d5024dcf73c712b38b | |
| parent | a984afd6a32ec3bd5011659362afaf81a4bc787e (diff) | |
| parent | 34264f0b0aff2a1bc33f64591e2095f4ce17a3e1 (diff) | |
Merge pull request #2016 from dalf/proxify-dataurl
[mod] don't try to proxify data URL.
| -rwxr-xr-x | searx/webapp.py | 11 |
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) |