Convert result_proxy.key into bytearray if necessary

This commit is contained in:
Sandro Jäckel 2022-07-18 01:19:00 +02:00
parent 7bf4e8d12d
commit e59b9a1932
No known key found for this signature in database
GPG Key ID: 3AF5A43A3EECC2E5

View File

@ -325,7 +325,10 @@ def proxify(url: str):
url_params = dict(mortyurl=url) url_params = dict(mortyurl=url)
if settings['result_proxy'].get('key'): if settings['result_proxy'].get('key'):
url_params['mortyhash'] = hmac.new(settings['result_proxy']['key'], url.encode(), hashlib.sha256).hexdigest() key = settings['result_proxy']['key']
if isinstance(key, str):
key = bytearray(key.encode())
url_params['mortyhash'] = hmac.new(key, url.encode(), hashlib.sha256).hexdigest()
return '{0}?{1}'.format(settings['result_proxy']['url'], urlencode(url_params)) return '{0}?{1}'.format(settings['result_proxy']['url'], urlencode(url_params))