Browse Source

[fix] image proxify utf urls

Adam Tauber 10 years ago
parent
commit
c711212662
1 changed files with 3 additions and 4 deletions
  1. 3
    4
      searx/webapp.py

+ 3
- 4
searx/webapp.py View File

215
     if url.startswith('//'):
215
     if url.startswith('//'):
216
         url = 'https:' + url
216
         url = 'https:' + url
217
 
217
 
218
-    url = url.encode('utf-8')
219
-
220
     if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
218
     if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
221
         return url
219
         return url
222
 
220
 
223
-    h = hashlib.sha256(url + settings['server']['secret_key'].encode('utf-8')).hexdigest()
221
+    hash_string = url + settings['server']['secret_key']
222
+    h = hashlib.sha256(hash_string.encode('utf-8')).hexdigest()
224
 
223
 
225
     return '{0}?{1}'.format(url_for('image_proxy'),
224
     return '{0}?{1}'.format(url_for('image_proxy'),
226
-                            urlencode(dict(url=url, h=h)))
225
+                            urlencode(dict(url=url.encode('utf-8'), h=h)))
227
 
226
 
228
 
227
 
229
 def render(template_name, override_theme=None, **kwargs):
228
 def render(template_name, override_theme=None, **kwargs):