Skip to content

Fix "Invalid base32-encoded string" error if there are ignored characters #148029

@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

Yet one error I missed. Base32 decoder report the number of all character, not alphabet characters, this contradicts with the condition for valid number.

>>> import base64
>>> base64.b32decode(b' ABCDEF==', ignorechars=b' ')
binascii.Error: Invalid base32-encoded string: number of data characters (7) cannot be 1, 3, or 6 more than a multiple of 8

7 is not 1, 3, or 6 more than a multiple of 8. Ignored characters (spaces) should not be counted.

Base64 decoder reports it correctly. It ignores non-alphabetic characters by default, so this is common case. Base32 decoder got the ignorechars parameter only recently.

Linked PRs

Metadata

Metadata

Labels

3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions