Repository navigation
Python implementation of json.loads() accepts non-ascii digits #125682
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Oct 18, 2024 Why is this a bug?
intandfloatsupport this as well:>>> int("\uff10") 0 >>> float("0e\uff10") 0.0
Arguably, the bug is that the C implementation does not support it.
This can indeed be considered a bug, since it does not conform to the JSON specification in the standards.
See, for example, Section 6: Numbers in IETF RFC 8259, which clearly defines the supported digits.
Reacted by Peter Bierma and Nice Zombies- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes
on Oct 18, 2024 Ah, I've applied the appropriate labels. Thank you for clarification :)
Reacted by Tal Einat- changed the title
[-]Python implementation of `json.loads()` accepts unicode digits[/-][+]Python implementation of `json.loads()` accepts non-ascii digits[/+]on Oct 18, 2024 - added a commit that references this issue
on Oct 18, 2024 Good spot!
Reacted by Nice Zombies
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
You should be careful when matching unicode regexes:
cpython/Lib/json/scanner.py
Lines 11 to 13 in a0f5c8e
I think it's safer to use
[0-9]instead of\dhere.CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
json.loads()accepts non-ascii digits #125687