base64Decode: clearer error message when an invalid character is detected

Output the offending string in its entirety to provide context.

(cherry picked from commit dc3ccf02bfd4d359228b54f5c24ae2b6caf6428e)
This commit is contained in:
Brian McGee 2023-07-31 18:40:45 +01:00 committed by Fabián Heredia Montiel
parent 8ab5743904
commit 2c095fa5a6

View file

@ -182,7 +182,7 @@ std::string base64Decode(std::string_view s)
char digit = base64DecodeChars[(unsigned char) c]; char digit = base64DecodeChars[(unsigned char) c];
if (digit == npos) if (digit == npos)
throw Error("invalid character in Base64 string: '%c'", c); throw Error("invalid character in Base64 string: '%c' in '%s'", c, s.data());
bits += 6; bits += 6;
d = d << 6 | digit; d = d << 6 | digit;