🐛 Fix base64 _decode Double Padding Detection
#345
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🕓 Changelog
This PR fixes incorrect padding detection in the
base64_decodefunction. The logic incorrectly identified/or_(index63) as the padding character instead of=(index64), and checked single padding before double padding. This caused Base64 strings with/or_in the third position (e.g.AA/AorAA_A) to be incorrectly truncated, and strings with double padding (==) to be mishandled. This patch corrects the index to64, reorders the conditional checks to handle double padding before single padding, and adds an assertion to reject invalid padding combinations. Since thebase64contract is not used in production, this bug poses no security risk. Thanks to @Leminkay for identifying this bug!🐶 Cute Animal Picture