Skip to content

[5.0 -> main] Fix base64 encoding - take 2#1893

Merged
heifner merged 7 commits into
mainfrom
GH-1461-base64-pad-main
Nov 13, 2023
Merged

[5.0 -> main] Fix base64 encoding - take 2#1893
heifner merged 7 commits into
mainfrom
GH-1461-base64-pad-main

Conversation

@heifner

@heifner heifner commented Nov 13, 2023

Copy link
Copy Markdown
Contributor

#1482 fixed base64 encoding by removing the unneeded extra = that variant added to base64 encoded data. However, it also updated the base64 library with a stricter one. This PR leaves the old base64 encoding/decoding library but does remove the extra = from the base64 encoded data so non-fc base64 decoders will not claim the data is invalid.

This change still breaks backward compatibility with 3.2 & 4.0 cleos/nodeos. PRs to 3.2 (#1889) and 4.0 will be created that will allow them to work with this new base64 encoding (they will no longer expect the invalid = character).

PR #1886 reverts #1482. This PR provided an alternative fix for #1461.

Included in this PR is an optimization to the existing base64_decode to avoid a copy for our use-cases by returning a vector<char> instead of a string.
Included in this PR is a change to the nodeos_run_test.py to keep the keosd running with passed --leaving-running which is useful for local testing. This was used to manually test using 3.2 cleos with 5.0.

Merges release/5.0 into main including #1888

Resolves #1461

@heifner heifner added the OCI Work exclusive to OCI team label Nov 13, 2023
Comment thread libraries/libfc/test/test_base64.cpp Outdated
Comment on lines +30 to +31
std::string b64_str(b64.begin(), b64.end());
BOOST_CHECK_EQUAL(expected_output, b64_str);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, not a required change, just a suggestion for here and the few next instances of the same pattern.

Suggested change
std::string b64_str(b64.begin(), b64.end());
BOOST_CHECK_EQUAL(expected_output, b64_str);
BOOST_CHECK_EQUAL(std::string_view(expected_output), std::string_view(b64.begin(), b64.end()));

@heifner heifner merged commit f4b7ace into main Nov 13, 2023
@heifner heifner deleted the GH-1461-base64-pad-main branch November 13, 2023 23:29
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.

Invalid Base64 padding returned by APIs

3 participants