-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Fix "Invalid base32-encoded string" error if there are ignored characters #148029
Copy link
Copy link
Open
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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 87 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error