fix(json): use two-char short forms \b and \f in JSON.stringify (#5047)#5048
Merged
Conversation
QuoteJSONString (ECMA-262) defines two-character escapes for backspace (U+0008) and formfeed (U+000C); Perry emitted the generic 4-hex-digit unicode escape for both, breaking byte-for-byte parity with Node and snapshot tests. Tab/newline/CR already used the short forms. Other control characters (e.g. U+000B) keep the \uXXXX form, matching the spec.
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.
Fixes #5047.
Problem
QuoteJSONString(ECMA-262 §25.5.2.2) defines two-character escapes for backspace (U+0008) and formfeed (U+000C). Perry used the short forms for tab/newline/CR but fell back to the generic 4-hex-digit\uXXXXescape for\band\f. Both parse back identically, but it breaks byte-for-byte parity with Node and snapshot tests.Fix
Add
0x08 → \\band0x0c → \\fto the escape table injson/stringify.rs(single escape site). Other control characters (e.g. U+000B) keep the\uXXXXform, per spec.Validation
stringify_uses_two_char_short_forms_for_backspace_and_formfeed(also pins that U+000B keeps the hex form); fulljson::test module passes (14/14).Code-only PR per the external-metadata convention — version bump + changelog left for merge time.