mirror of
				https://github.com/searxng/searxng
				synced 2024-01-01 19:24:07 +01:00 
			
		
		
		
	Merge pull request #2016 from dalf/proxify-dataurl
[mod] don't try to proxify data URL.
This commit is contained in:
		
						commit
						ccb1fe11d7
					
				
					 1 changed files with 9 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue