Skip to content

Commit

Permalink
Fix parsing of content-type like "text/html; charset=UTF-8"
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas17 committed Aug 31, 2021
1 parent 5ff56a0 commit a0097b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion banktoken/banelcotoken.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def fetch_encrypted_payload(bank_id, activation_code):
raise RuntimeError("status_code not 200") # FIXME better exception

content_type = r.headers.get('Content-Type', '')
# if there are any parameters like "text/html;charset=utf-8" we want to remove them
content_type = content_type.partition(';')[0].strip()

if content_type == 'application/javascript':
m = re.fullmatch(rb'callback\(\["(.*)"\]\)', r.content)
if m is None:
Expand All @@ -60,7 +63,7 @@ def fetch_encrypted_payload(bank_id, activation_code):
else:
raise RuntimeError("Got unknown error")
else:
raise RuntimeError("Got unexpected content type")
raise RuntimeError("Got unexpected content type: %r" % content_type)

def decrypt_seed(payload, passcode):
decrypted_payload = jscrypto.aesCtrDecrypt(payload, passcode, 256)
Expand Down

0 comments on commit a0097b7

Please sign in to comment.