[New-bugs-announce] [issue39055] base64.b64decode() with validate=True does not raise for a trailing \n

Serhiy Storchaka report at bugs.python.org
Sun Dec 15 12:21:28 EST 2019


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

If validate=True is passed to base64.b64decode(), it should raise a binascii.Error if the input contains any character not from the acceptable alphabet.

But it does not raise if the input ends with a single \n. It raises if the input ends with a multiple \n or with any other whitespace character. Only a single \n is accepted.

This is an implementation artifact. A regular exception ending with $ is used to validate an input. But $ matches not only end of string. It matches also an empty string before the trailing \n.

Similar errors are also occurred in other sites. I'll open separate issues for different cases.

----------
components: Library (Lib)
messages: 358438
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: base64.b64decode() with validate=True does not raise for a trailing \n
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39055>
_______________________________________


More information about the New-bugs-announce mailing list