diff --git a/libraries/libfc/src/variant.cpp b/libraries/libfc/src/variant.cpp index 4b81c3c06c..41946ae2ac 100644 --- a/libraries/libfc/src/variant.cpp +++ b/libraries/libfc/src/variant.cpp @@ -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( b64.begin(), b64.end() ) } ); + } catch(const std::exception&) { + // unable to decode, return raw chars } return blob( { std::vector( str.begin(), str.end() ) } ); }