First of all, thanks for the implementation. I'd like to report a small bug. In some cases of URL-safe base64 strings, the decoding fails, because the exception If input is correct, this line should never be reached. is thrown.
If you want to check the code directly, it's pretty straightforward. Inside base64_decode(), in the main loop, there is a missing condition in the last if, which checks the last of character in the current quartet, namely the pos+3-th.
Hello,
First of all, thanks for the implementation. I'd like to report a small bug. In some cases of URL-safe base64 strings, the decoding fails, because the exception
If input is correct, this line should never be reached.
is thrown.If you want to check the code directly, it's pretty straightforward. Inside
base64_decode()
, in the main loop, there is a missing condition in the last if, which checks the last of character in the current quartet, namely thepos+3
-th.I believe that the same check done for the
pos+2
-th char should be done for thepos+3
-th charHow to reproduce:
Just create a bytestring with length= 3k-1, encode it as URL-safe and decode it.