Browse Source

[fix] codec can't encode character inside image_proxify

Thomas Pointhuber 10 years ago
parent
commit
14079ea2b0
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      searx/webapp.py

+ 5
- 3
searx/webapp.py View File

@@ -215,10 +215,12 @@ def image_proxify(url):
215 215
     if url.startswith('//'):
216 216
         url = 'https:' + url
217 217
 
218
+    url = url.encode('utf-8')
219
+
218 220
     if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
219 221
         return url
220 222
 
221
-    h = hashlib.sha256(url.encode('utf-8') + settings['server']['secret_key'].encode('utf-8')).hexdigest()
223
+    h = hashlib.sha256(url + settings['server']['secret_key'].encode('utf-8')).hexdigest()
222 224
 
223 225
     return '{0}?{1}'.format(url_for('image_proxy'),
224 226
                             urlencode(dict(url=url, h=h)))
@@ -553,12 +555,12 @@ def preferences():
553 555
 
554 556
 @app.route('/image_proxy', methods=['GET'])
555 557
 def image_proxy():
556
-    url = request.args.get('url')
558
+    url = request.args.get('url').encode('utf-8')
557 559
 
558 560
     if not url:
559 561
         return '', 400
560 562
 
561
-    h = hashlib.sha256(url.encode('utf-8') + settings['server']['secret_key'].encode('utf-8')).hexdigest()
563
+    h = hashlib.sha256(url + settings['server']['secret_key'].encode('utf-8')).hexdigest()
562 564
 
563 565
     if h != request.args.get('h'):
564 566
         return '', 400