Open adiospace opened 4 years ago
Dart's base64 decoder is deliberately pedantic. That increases the chance that an accidentally truncated input string is detected (it has a 3/4 chance of being invalid).
Maybe we should add an option to accept non-padded data, instead of requiring it to be normalized before decoding.
when it has non-padded data,we can add padded data(=) before decoder it.
is there a way to handle the error when it is throw?
Issue with dart:convert
base64.decode
orbase64Url.decode
throws a FormatException('Invalid length, must be multiple of four") when decoding the following base64 encoded string"eyJlbWFpbCI6ImFnb2xhcnVAZ21haWwuY29tIiwibmFtZSI6IkFkcmlhbiBPbGFydSIsInRva2VuIjoiS3FBd2J2M3A0cVZVM3V1Mzg4Z3dqQUVMIiwidXNlcm5hbWUiOiJhZHJpYW5fb2xhcnUiLCJpZCI6NDAyNjIsInJvbGUiOiJ1c2VyIn0"
.It works just fine in JavaScript env using
atob
.To make it work I had to normalize it first using
base64.normalize
.We can close this if it's ok to normalize it explicitly I was just expecting it to work directly using
base64.decode
method.Dart VM version: 2.6.0 (Thu Oct 24 17:52:22 2019 +0200) on "macos_x64"