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