Add the ignorechars parameter in the Base64 decoder
Feature or enhancement
Earlier standards for Base64 (RFC 1421, RFC 1521) on which the base64 and binascii modules are based, specified that any non-alphabet characters should be ignored, and this is the default behavior of these modules. More modern standard (RFC 4648) considers this a vulnerability, and specify that they should be rejected until the upper lever document states otherwise. Thus, strict_mode/validate parameters were added. But they are "all-or-nothing" -- either all non-alphabet characters are rejected, or other errors are ignored. In some cases we need to ignore only the part of errors -- for example, ignore newlines and whitespaces, but not other invalid characters, or ignore padding errors.
a85decode() has parameter ignorechars which could also be used to control Base64 decoding.
Linked PRs
- gh-144001: Add ignorechars parameter to Base64 decoder #144009
- gh-144001: Support ignorechars in binascii.a2b_base64() and base64.b64decode() #144024
- gh-144001: Support ignoring the invalid pad character in Base64 decoding #144306
- gh-144001: Simplify Base64 decoding with altchars and ignorechars specified #144324