Merge pull request #11521 from NixOS/mergify/bp/2.24-maintenance/pr-8766

base64Decode: clearer error message when an invalid character is detected (backport #8766)
This commit is contained in:
Valentin Gagarin 2024-09-19 11:29:21 +02:00 committed by GitHub
commit fc1d6b2f03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -260,8 +260,9 @@ std::string base64Decode(std::string_view s)
if (c == '\n') continue;
char digit = base64DecodeChars[(unsigned char) c];
if (digit == npos)
throw Error("invalid character in Base64 string: '%c'", c);
if (digit == npos) {
throw Error("invalid character in Base64 string: '%c' in '%s'", c, s.data());
}
bits += 6;
d = d << 6 | digit;