mirror of
https://github.com/searxng/searxng
synced 2024-11-09 01:10:26 +00:00
Merge pull request #207 from pointhi/hash_fix
[fix] hash error if url is including non ascii characters
This commit is contained in:
commit
4a20fc202e
@ -215,10 +215,12 @@ def image_proxify(url):
|
|||||||
if url.startswith('//'):
|
if url.startswith('//'):
|
||||||
url = 'https:' + url
|
url = 'https:' + url
|
||||||
|
|
||||||
|
url = url.encode('utf-8')
|
||||||
|
|
||||||
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 + 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)))
|
||||||
@ -553,12 +555,12 @@ def preferences():
|
|||||||
|
|
||||||
@app.route('/image_proxy', methods=['GET'])
|
@app.route('/image_proxy', methods=['GET'])
|
||||||
def image_proxy():
|
def image_proxy():
|
||||||
url = request.args.get('url')
|
url = request.args.get('url').encode('utf-8')
|
||||||
|
|
||||||
if not url:
|
if not url:
|
||||||
return '', 400
|
return '', 400
|
||||||
|
|
||||||
h = hashlib.sha256(url + settings['server']['secret_key']).hexdigest()
|
h = hashlib.sha256(url + settings['server']['secret_key'].encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
if h != request.args.get('h'):
|
if h != request.args.get('h'):
|
||||||
return '', 400
|
return '', 400
|
||||||
|
Loading…
Reference in New Issue
Block a user