Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.2 -> 4.0] Do not require trailing = for base64 encoded strings #1892

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions libraries/libfc/src/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,14 @@ blob variant::as_blob()const
{
const string& str = get_string();
if( str.size() == 0 ) return blob();
if( str.back() == '=' )
{
std::string b64 = base64_decode( get_string() );
try {
// variant adds `=` to end of base64 encoded string (see as_string() above) which produces invalid base64
// variant in 5.0 no longer appends the '=' character to conform to valid base64 encoding
// fc version of base64_decode allows for extra `=` at the end of the string
std::string b64 = base64_decode( str );
return blob( { std::vector<char>( b64.begin(), b64.end() ) } );
} catch(const std::exception&) {
// unable to decode, return raw chars
}
return blob( { std::vector<char>( str.begin(), str.end() ) } );
}
Expand Down