Repository navigation
Use post-serialization RFC 8259 Unicode escaping for JSON-LD output - #64
Merged
Merged
Conversation
Move character escaping out of the JSON.stringify replacer and onto the serialized JSON string using standard RFC 8259 Unicode escape sequences (`\u003c`, `\u003e`, `\u0026`, `\u2028`, `\u2029`, `\ufffe`, `\uffff`, and unpaired UTF-16 surrogates while preserving valid surrogate pairs). This ensures consistent escaping across all serialized JSON output (including property names and values), preserves lossless JSON.parse() round-tripping without HTML-entity encoding in string values, keeps null property omission via omitNullReplacer, and normalizes options.space to valid RFC 8259 indentation whitespace or finite numbers.
Swap react-test-renderer and @types/react-test-renderer for react-dom and @types/react-dom in devDependencies, and render <JsonLd> in test/jsonld_component_test.tsx using renderToStaticMarkup. This removes the React 19 deprecation warnings and act()/IS_REACT_ACT_ENVIRONMENT boilerplate while directly verifying serialized <script> output. Add DOM to test/tsconfig.json lib, set `"types": []` in src/tsconfig.json and type-test/tsconfig.json, and mark the root tsconfig.json with `"files": []` so @types/react-dom type-checks cleanly in tests without adding DOM types to src/ or type-test/.
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.
Summary
JSON.stringifyreplacer to post-serialization RFC 8259 Unicode escaping (\u003c,\u003e,\u0026,\u2028,\u2029,\ufffe,\uffff, and unpaired UTF-16 surrogates while preserving valid surrogate pairs). This applies escaping consistently across the full serialized JSON output (both property names and values) and preserves losslessJSON.parse()round-tripping per RFC 8259.omitNullReplacerfor omittingnullobject properties and normalizeoptions.spacefrom own properties to finite numbers (0..10) or strict RFC 8259 whitespace (/^[ \t\r\n]*$/).react-test-rendererwithreact-dom/server(renderToStaticMarkup) intest/jsonld_component_test.tsx, with correspondingtsconfigupdates sosrc/andtype-test/remain DOM-free.2.0.2.