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] Do not require trailing = for base64 encoded strings #1889

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

heifner
Copy link
Member

@heifner heifner commented Nov 13, 2023

All previous versions of nodeos required a trailing = for base64 encoded strings. fc::variant appends an extra = for all of its base64 encoded strings. However, non-fc base64 encoders do not add an extra = when one is not needed. This PR modifies fc::variant to support non-fc base64 encoded strings that do not have the extra =.

In 5.0, fc::variant was updated to not add the extra = to base64 encoded strings. See #1888. This PR allows nodeos to support the new 5.0 version of base64 encoded strings.

Issue #1461

@heifner heifner added the OCI Work exclusive to OCI team label Nov 13, 2023
Copy link
Contributor

@greg7mdp greg7mdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I assume that if there is an extra = character at the end, base64_decode ignores it, right?

@heifner
Copy link
Member Author

heifner commented Nov 13, 2023

So I assume that if there is an extra = character at the end, base64_decode ignores it, right?

Yes. And there is an existing test that verifies that:

BOOST_AUTO_TEST_CASE(base64dec_extraequals) try {
auto input = "YWJjMTIzJCYoKSc/tPUB+n5h========="s;
auto expected_output = "abc123$&()'?\xb4\xf5\x01\xfa~a"s;
BOOST_CHECK_EQUAL(expected_output, base64_decode(input));
} FC_LOG_AND_RETHROW();

return blob( { std::vector<char>( b64.begin(), b64.end() ) } );
} catch(const std::exception&) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fc::assert_exception?

Copy link
Member Author

@heifner heifner Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation uses .at() so std::out_of_range is maybe possible, although not sure if really is because of the while (pos < length_of_string)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants