Parcourir la source

[fix] hash error if url is including non ascii characters

Thomas Pointhuber il y a 10 ans
Parent
révision
38302ef58b
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2
    2
      searx/webapp.py

+ 2
- 2
searx/webapp.py Voir le fichier

218
     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'):
219
         return url
219
         return url
220
 
220
 
221
-    h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest()
221
+    h = hashlib.sha256(url.encode('utf-8') + settings['server']['secret_key'].encode('utf-8')).hexdigest()
222
 
222
 
223
     return '{0}?{1}'.format(url_for('image_proxy'),
223
     return '{0}?{1}'.format(url_for('image_proxy'),
224
                             urlencode(dict(url=url, h=h)))
224
                             urlencode(dict(url=url, h=h)))
558
     if not url:
558
     if not url:
559
         return '', 400
559
         return '', 400
560
 
560
 
561
-    h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest()
561
+    h = hashlib.sha256(url.encode('utf-8') + settings['server']['secret_key'].encode('utf-8')).hexdigest()
562
 
562
 
563
     if h != request.args.get('h'):
563
     if h != request.args.get('h'):
564
         return '', 400
564
         return '', 400