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

This commit is contained in:
Thomas Pointhuber 2015-02-01 10:07:53 +01:00
parent 78828efdb0
commit 38302ef58b
1 changed files with 2 additions and 2 deletions

View File

@ -218,7 +218,7 @@ def image_proxify(url):
if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'): if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
return url return url
h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest() h = hashlib.sha256(url.encode('utf-8') + settings['server']['secret_key'].encode('utf-8')).hexdigest()
return '{0}?{1}'.format(url_for('image_proxy'), return '{0}?{1}'.format(url_for('image_proxy'),
urlencode(dict(url=url, h=h))) urlencode(dict(url=url, h=h)))
@ -558,7 +558,7 @@ def image_proxy():
if not url: if not url:
return '', 400 return '', 400
h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest() h = hashlib.sha256(url.encode('utf-8') + settings['server']['secret_key'].encode('utf-8')).hexdigest()
if h != request.args.get('h'): if h != request.args.get('h'):
return '', 400 return '', 400