mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-39055: Reject a trailing \n in base64.b64decode() with validate=True. (GH-17616)
This commit is contained in:
parent
41ec17e45d
commit
b19c0d77e6
3 changed files with 4 additions and 1 deletions
|
@ -82,7 +82,7 @@ def b64decode(s, altchars=None, validate=False):
|
|||
altchars = _bytes_from_decode_data(altchars)
|
||||
assert len(altchars) == 2, repr(altchars)
|
||||
s = s.translate(bytes.maketrans(altchars, b'+/'))
|
||||
if validate and not re.match(b'^[A-Za-z0-9+/]*={0,2}$', s):
|
||||
if validate and not re.fullmatch(b'[A-Za-z0-9+/]*={0,2}', s):
|
||||
raise binascii.Error('Non-base64 digit found')
|
||||
return binascii.a2b_base64(s)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue