You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Escape NUL before decimal digits unambiguously - #121
A NUL character followed by a decimal digit is currently encoded as \01 (or another digit), which JSON5 does not allow and loads() cannot read back. Use \^@ before decimal digits while retaining \0 elsewhere.
Regression tests round-trip all 10 digits through four quoting modes and both ASCII settings. All 80 new subtests fail before the fix; the full suite passes (80 tests, 100 subtests), and changed-file Ruff lint/format checks pass on Python 3.13. The complete supported Python/OS matrix has not been run.
Ah, whoops ... I didn't realize your commit message was so terse (just the one line). In the future, please write a description that explains the problem and the fix more fully so that someone reading the change history doesn't necessarily have to go look at the PR or the actual diff to get a more detailed understanding of the change.
I would've written something like:
JSON5 (like Javascript but unlike JSON) allows \0 as an escape sequence in a string as an alternative to \u0000, but only if the following character is not a decimal digit. The current implementation was not enforcing that in json.dumps(), and always using \0 and so json.dumps("\x001') would be encoded as "\01", which was illegal. This fix makes it return "\u00001" in this situation instead (though json.dumps("\x00foo") will still return "\0foo".
Not a big deal, though. Thanks again :).
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
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.
A NUL character followed by a decimal digit is currently encoded as
\01(or another digit), which JSON5 does not allow andloads()cannot read back. Use\^@before decimal digits while retaining\0elsewhere.Regression tests round-trip all 10 digits through four quoting modes and both ASCII settings. All 80 new subtests fail before the fix; the full suite passes (80 tests, 100 subtests), and changed-file Ruff lint/format checks pass on Python 3.13. The complete supported Python/OS matrix has not been run.