Skip to content

gh-162353: Fix Base32 padding with ignored padding characters - #162423

Open
ElDShell wants to merge 5 commits into
python:mainfrom
ElDShell:fix-binascii-base32-padding
Open

ElDShell wants to merge 5 commits into
python:mainfrom
ElDShell:fix-binascii-base32-padding

Conversation

@ElDShell

@ElDShell ElDShell commented Nov 22, 2026 •

Copy link
Copy Markdown

Summary

Fixes an issue in binascii.a2b_base32() where ignored padding characters (=) are incorrectly counted as trailing padding.

The padding counter is now reset upon encountering a valid Base32 data character, ensuring that only trailing padding characters are taken into account during padding validation.

Changes

  • Reset the padding counter when processing a valid Base32 data character.
  • Add regression tests covering ignored padding characters both before and within Base32 data.
  • Ensure that invalid padding raises a binascii.Error with the message Incorrect padding.

Issue

Fixes #162353

@python-cla-bot

python-cla-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Nov 22, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app

bedevere-app Bot commented Nov 22, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app

bedevere-app Bot commented Nov 22, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

corner case: base64.b32decode ignorechars=b'=' miscounts padding

1 participant