Anonymous3-a · GitHub

Bug report

Bug description:

If you run

>>> import base64
>>> base64.b64decode("/+/+")

it gives

b'\xff\xef\xfe'

This is expected.
If you run

>>> base64.b64decode("_-_-", altchars="-_")

It gives the same output.
This is expected.
However, if you run

>>> base64.b64decode("/+/+", altchars="-_")

It also gives the same output.
This is not expected.

This is concerning because I'm trying to use file safe base64 (urlsafe_b64decode/encode do not have validate arg, which I need). I can work around this by also checking for / and + as well.

CPython versions tested on:

3.9, 3.11

Operating systems tested on:

Linux, Other

Linked PRs

Read the original on github.com ↗