Repository navigation
Reject JSON input truncated at an embedded NUL - #245
Merged
lelit merged 1 commit intoOct 12, 2026
Merged
Conversation
Contributor
|
Thanks for the PR, I'm going to merge it. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
loads('123\0garbage'),load()andDecoder()currently return123, silently ignoring the NUL and everything after it. Refs #241, specifically the reportedjts-8259-n_multidigit_number_then_00compliance failure (123\0).RapidJSON uses NUL as its end-of-input sentinel. After an otherwise successful parse, check the actual input length or the stream wrapper's EOF state. Report remaining input through the existing
JSONDecodeErrorpath, retaining the byte offset and the standard document-root error message. Escaped NULs in JSON strings remain valid.Regression tests cover all six decoding routes, scalar/container documents, UTF-8 byte offsets, bytes/bytearray inputs, and stream chunk boundaries. This change does not alter the parse-flag dispatch addressed by #243.
Validation on macOS with CPython 3.11.5, using a locally built C++ extension:
pytest tests -o addopts='' -q: 1029 passed, 17 skipped, 2 xfailed. The unchanged base passes its original suite: 937 passed, 17 skipped, 2 xfailed.python -m mypy.stubtest rapidjson, Python compilation of the modified test files, andgit diff --checkpass. The repository has no configured lint command.docs/loads.rst:114, where the native-mode large integer is represented as1.2345678901234568e+29instead of1.2345678901234566e+29. A separately built, unchanged checkout at7337070f5bff88c8dc9803eded753f714c6fc1c0reproduces the identical failure. Both runs also report the existing missing_staticdirectory warning.AI disclosure: OpenAI Codex generated and locally validated this patch and its tests. No separate human code review has been performed. Hosted CI, other Python versions/platforms, debug/free-threaded builds, sanitizers, and performance benchmarks have not been verified locally.