瀏覽代碼

[fix] image proxify utf urls

Adam Tauber 10 年之前
父節點
當前提交
c711212662
共有 1 個文件被更改,包括 3 次插入4 次删除
  1. 3
    4
      searx/webapp.py

+ 3
- 4
searx/webapp.py 查看文件

@@ -215,15 +215,14 @@ def image_proxify(url):
215 215
     if url.startswith('//'):
216 216
         url = 'https:' + url
217 217
 
218
-    url = url.encode('utf-8')
219
-
220 218
     if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
221 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 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 228
 def render(template_name, override_theme=None, **kwargs):