Skip to content

fix: validate that all characters after first padding character in Base64 decode#7491

Merged
DenizAltunkapan merged 2 commits into
TheAlgorithms:masterfrom
priyanshuvishwakarma273403:fix-7482-base64-padding-validation
Jun 22, 2026
Merged

fix: validate that all characters after first padding character in Base64 decode#7491
DenizAltunkapan merged 2 commits into
TheAlgorithms:masterfrom
priyanshuvishwakarma273403:fix-7482-base64-padding-validation

Conversation

@priyanshuvishwakarma273403

Copy link
Copy Markdown
Contributor

Description

Fixes a bug where Base64.decode accepted malformed inputs with data characters appearing after a padding character = (e.g. "QQ=Q").

Related Issue

Fixes #7482

Changes

  • Updated Base64.decode to assert that all characters starting from the first = character to the end of the input string are also =.
  • Added unit test cases in Base64Test.java to prevent regression.

@codecov-commenter

codecov-commenter commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.88%. Comparing base (a508fd2) to head (770e092).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #7491   +/-   ##
=========================================
  Coverage     79.88%   79.88%           
- Complexity     7340     7343    +3     
=========================================
  Files           809      809           
  Lines         23847    23851    +4     
  Branches       4694     4697    +3     
=========================================
+ Hits          19050    19054    +4     
- Misses         4035     4036    +1     
+ Partials        762      761    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DenizAltunkapan DenizAltunkapan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@priyanshuvishwakarma273403 very good, thank you.

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) June 22, 2026 16:14
@DenizAltunkapan DenizAltunkapan merged commit 0fe06ac into TheAlgorithms:master Jun 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Base64.decode accepts malformed input: a padding '=' followed by a data character

3 participants