@@ -69,6 +69,7 @@ from searx.plugins import plugins
69from searx.preferences import Preferences, ValidationException
69from searx.preferences import Preferences, ValidationException
70from searx.answerers import answerers
70from searx.answerers import answerers
71from searx.url_utils import urlencode, urlparse, urljoin
71from searx.url_utils import urlencode, urlparse, urljoin
72+from searx.utils import new_hmac
73# check if the pyopenssl package is installed.
74# check if the pyopenssl package is installed.
74# It is needed for SSL connection without trouble, see #298
75# It is needed for SSL connection without trouble, see #298
@@ -290,7 +291,7 @@ def image_proxify(url):
290 if settings.get('result_proxy'):
291 if settings.get('result_proxy'):
291 return proxify(url)
292 return proxify(url)
293− h = hmac.new(settings['server']['secret_key'], url.encode('utf-8'), hashlib.sha256).hexdigest()
294+ h = new_hmac(settings['server']['secret_key'], url.encode('utf-8'))
295 return '{0}?{1}'.format(url_for('image_proxy'),
296 return '{0}?{1}'.format(url_for('image_proxy'),
296 urlencode(dict(url=url.encode('utf-8'), h=h)))
297 urlencode(dict(url=url.encode('utf-8'), h=h)))
@@ -704,7 +705,7 @@ def image_proxy():
704 if not url:
705 if not url:
705 return '', 400
706 return '', 400
707− h = hmac.new(settings['server']['secret_key'], url, hashlib.sha256).hexdigest()
708+ h = new_hmac(settings['server']['secret_key'], url)
709 if h != request.args.get('h'):
710 if h != request.args.get('h'):
710 return '', 400
711 return '', 400
@@ -731,7 +732,7 @@ def image_proxy():
731 logger.debug('image-proxy: wrong content-type: {0}'.format(resp.headers.get('content-type')))
732 logger.debug('image-proxy: wrong content-type: {0}'.format(resp.headers.get('content-type')))
732 return '', 400
733 return '', 400
734− img = ''
735+ img = b''
735 chunk_counter = 0
736 chunk_counter = 0
737 for chunk in resp.iter_content(1024 * 1024):
738 for chunk in resp.iter_content(1024 * 1024):