GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add the ignorechars parameter in the Base64 decoder · Issue #144001 · python/cpython

Add the ignorechars parameter in the Base64 decoder #144001

New issue
Copy link
New issue
Copy link
Closed
Closed
Add the ignorechars parameter in the Base64 decoder#144001
Copy link
Assignees
serhiy-storchaka
Labels
3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@serhiy-storchaka
serhiy-storchaka
opened on Jan 18, 2026
Issue body actions

Feature or enhancement

Earlier standards for Base64 (RFC 1421, RFC 1521) on which the base64 and binascii modules are based, specified that any non-alphabet characters should be ignored, and this is the default behavior of these modules. More modern standard (RFC 4648) considers this a vulnerability, and specify that they should be rejected until the upper lever document states otherwise. Thus, strict_mode/validate parameters were added. But they are "all-or-nothing" -- either all non-alphabet characters are rejected, or other errors are ignored. In some cases we need to ignore only the part of errors -- for example, ignore newlines and whitespaces, but not other invalid characters, or ignore padding errors.

a85decode() has parameter ignorechars which could also be used to control Base64 decoding.

Linked PRs

  • gh-144001: Add ignorechars parameter to Base64 decoder #144009
  • gh-144001: Support ignorechars in binascii.a2b_base64() and base64.b64decode() #144024
  • gh-144001: Support ignoring the invalid pad character in Base64 decoding #144306
  • gh-144001: Simplify Base64 decoding with altchars and ignorechars specified #144324

Activity

  1. serhiy-storchaka
    self-assigned this
    on Jan 18, 2026
  2. serhiy-storchaka
    added
    type-featureA feature request or enhancementA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.15bugs and security fixesbugs and security fixes
    on Jan 18, 2026
  3. moneebullah25
    added a commit that references this issue on Jan 18, 2026

    pythongh-144001: Add ignorechars parameter to Base64 decoder

    2657098
  4. moneebullah25 commented on Jan 18, 2026

    @moneebullah25
    moneebullah25
    on Jan 18, 2026
    Contributor
    More actions

    Hi @serhiy-storchaka

    I've implemented this feature in PR #144009.

    This PR adds ignorechars parameter to binascii.a2b_base64() and base64.b64decode() with O(1) lookup table, tests, and NEWS entry.

    If this aligns with you have in your mind, feel free to merge or let me know what to cherry-pick from it. Otherwise If you'd prefer a different approach or it needs significant changes, please let me know or feel free to create your own implementation, if not I am happy to close mine in that case.

  5. moneebullah25
    added 2 commits that reference this issue on Jan 18, 2026

    pythongh-144001: Register ignorechars identifier in global strings

    c4b6a65

    pythongh-144001: removed news entry and blurbed it

    5cfb7da
  6. serhiy-storchaka
    added a commit that references this issue on Jan 19, 2026

    pythongh-144001: Support ignorechars in binascii.a2b_base64() and bas…

    1b0bb87
  7. serhiy-storchaka commented on Jan 19, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jan 19, 2026
    MemberAuthor
    More actions

    Sorry, @moneebullah25, but I already had my code before opening this issue. I only needed to solve a pair of corner cases.

    Reacted by Muneeb Ullah
  8. serhiy-storchaka
    added 2 commits that reference this issue on Jan 19, 2026

    pythongh-144001: Support ignorechars in binascii.a2b_base64() and bas…

    192d535

    pythongh-144001: Support ignorechars in binascii.a2b_base64() and bas…

    4f3847e
  9. serhiy-storchaka
    added a commit that references this issue on Jan 26, 2026

    gh-144001: Support ignorechars in binascii.a2b_base64() and base64.b6…

    7febbe6
  10. gpshead commented on Jan 26, 2026

    @gpshead
    gpshead
    on Jan 26, 2026
    Member
    More actions

    a followup PR is likely needed per #144024 (comment)

  11. serhiy-storchaka
    added 2 commits that reference this issue on Jan 28, 2026

    pythongh-144001: Support ignoring the invalid pad character in Base64…

    79f767a

    pythongh-144001: Support ignoring the invalid pad character in Base64…

    92067d2
  12. serhiy-storchaka commented on Jan 28, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jan 28, 2026
    MemberAuthor
    More actions

    PR #144306 extend the function of ignorechars and allows to support the following optional features (RFC 4648, section 3.3):

    Furthermore, such specifications MAY ignore the pad
    character, "=", treating it as non-alphabet data, if it is present
    before the end of the encoded data. If more than the allowed number
    of pad characters is found at the end of the string (e.g., a base 64
    string terminated with "==="), the excess pad characters MAY also be
    ignored.

    Now, if ignorechars contains the pad character '=', the pad characters presented before the end of the encoded data and the excess pad characters will be ignored.

  13. serhiy-storchaka
    added a commit that references this issue on Jan 29, 2026

    pythongh-144001: Simplify Base64 decoding with altchars and ignorecha…

    ed8e5ff
  14. serhiy-storchaka commented on Jan 29, 2026

    @serhiy-storchaka
    serhiy-storchaka
    on Jan 29, 2026
    MemberAuthor
    More actions

    And since ignorechars is a new parameter, no need to restore the deprecated behavior and emit corresponding warnings when both altchars and ignorechars are specified. #144324 makes it matching the future more secure behavior. It also makes the code simpler.

  15. serhiy-storchaka
    added a commit that references this issue on Feb 2, 2026

    gh-144001: Simplify Base64 decoding with altchars and ignorechars spe…

    c3b61ef
  16. Aniketsy
    added a commit that references this issue on Feb 3, 2026

    pythongh-144001: Simplify Base64 decoding with altchars and ignorecha…

    2e5794e
  17. serhiy-storchaka
    added a commit that references this issue on Feb 5, 2026

    gh-144001: Support ignoring the invalid pad character in Base64 decod…

    4644fed
  18. serhiy-storchaka
    closed this as completedon Feb 5, 2026
  19. thunder-coding
    added 3 commits that reference this issue on Feb 15, 2026

    pythongh-144001: Support ignorechars in binascii.a2b_base64() and bas…

    e7f7eed

    pythongh-144001: Simplify Base64 decoding with altchars and ignorecha…

    5113c50

    pythongh-144001: Support ignoring the invalid pad character in Base64…

    ebf72e2
  20. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-144001: Support ignoring the invalid pad character in Base64…

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

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

3.15bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.