FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-144001: Add ignorechars parameter to Base64 decoder by moneebullah25 · Pull Request #144009 · python/cpython · GitHub

/ cpython Public

gh-144001: Add ignorechars parameter to Base64 decoder - #144009

Closed
moneebullah25 wants to merge 6 commits into
python:mainfrom
moneebullah25:gh-144001-add-ignorechars-base64
Closed

gh-144001: Add ignorechars parameter to Base64 decoder#144009
moneebullah25 wants to merge 6 commits into
python:mainfrom
moneebullah25:gh-144001-add-ignorechars-base64

Conversation

moneebullah25 commented Jan 18, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

  • Add the ignorechars parameter to binascii.a2b_base64() and base64.b64decode()
  • When provided, only characters in this set will be silently ignored during decoding
  • Other non-base64 characters will cause a binascii.Error
  • Similar to the existing ignorechars parameter in base64.a85decode()

This addresses the feature request in #144001 where the existing strict_mode/validate parameters are "all-or-nothing" - either all non-alphabet characters are rejected, or all are ignored. The new ignorechars parameter allows selective filtering (e.g., ignoring whitespace while rejecting other invalid characters).

API

# Ignore only whitespace, reject other invalid chars
base64.b64decode(b'YWJj\n', ignorechars=b'\n')  # OK: b'abc'
base64.b64decode(b'YWJj!', ignorechars=b'\n')   # Error

# Strict: reject all non-base64
base64.b64decode(b'YWJj\n', ignorechars=b'')    # Error

# Default behavior unchanged
base64.b64decode(b'YWJj\n')                      # OK: b'abc' (ignores all)

Closes #144001

picnixz commented Jan 24, 2026

Copy link
Copy Markdown
Member

Closing since we will likely prefer Serhiy's PR for that. Thanks for the suggestion.

picnixz closed this Jan 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Add the ignorechars parameter in the Base64 decoder

2 participants


Back | FazBrowse Home | New Git URL