Skip to content

Commit

Permalink
Replace base64 decoding errors with BadData.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucian1900 authored and davidism committed Apr 13, 2016
1 parent f1ecd77 commit ec69312
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion itsdangerous.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ def base64_decode(string):
The result is also a bytestring.
"""
string = want_bytes(string, encoding='ascii', errors='ignore')
return base64.urlsafe_b64decode(string + b'=' * (-len(string) % 4))
string += b'=' * (-len(string) % 4)

try:
return base64.urlsafe_b64decode(string)
except (TypeError, ValueError):
raise BadData('Invalid base64-encoded data')


_int64_struct = struct.Struct('>Q')
Expand Down

0 comments on commit ec69312

Please sign in to comment.