-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace JSON11-produced hex escape codes with unicode escape codes #8355
base: main
Are you sure you want to change the base?
Replace JSON11-produced hex escape codes with unicode escape codes #8355
Conversation
❌ Invalid Prefix For Manual Changeset CreationInvalid description prefix. Found "fix". Only "skip" entry option is permitted for manual commit of changeset files. If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description. |
This may only be a partial fix for the overall issue. I found another JSON5-serialization PR at opensearch-project/opensearch-js#784 that will also need a similar patch. |
❌ Invalid Prefix For Manual Changeset CreationInvalid description prefix. Found "fix". Only "skip" entry option is permitted for manual commit of changeset files. If you were trying to skip the changelog entry, please use the "skip" entry option in the ##Changelog section of your PR description. |
JSON11.stringify produces JSON5 documents with hex escape codes (`\x1b`), which aren't standard JSON and cause `JSON.parse` to error. When using JSON11, replace all `\xXX` escape codes with the JSON-compatible equivalent Unicode escape codes (`\u00XX`). Partially addresses opensearch-project#7367. Signed-off-by: Will Jordan <[email protected]>
ac0eae9
to
1bb3782
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8355 +/- ##
==========================================
- Coverage 64.14% 60.92% -3.23%
==========================================
Files 3743 3749 +6
Lines 88849 89022 +173
Branches 13856 13898 +42
==========================================
- Hits 56993 54237 -2756
- Misses 31241 31423 +182
- Partials 615 3362 +2747
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I haven't managed to verify the updated package in my deployment, this patch fixed my issue for now so further followup has been a lower priority. I gave the updated json11 npm module source a quick look and the added option to disable the hex-escape code should work fine as an alternative to the changes here. It seems to be missing a corresponding commit in the GitHub repo though. Feel free to use the unit test in this PR to verify the module change works equally well to fix the issue. |
Description
JSON11.stringify produces JSON5 documents with hex escape codes (
\x1b
), which aren't standard JSON and causeJSON.parse
to error. When using JSON11, replace all\xXX
escape codes with the JSON-compatible equivalent Unicode escape codes (\u00XX
).Issues Resolved
FixesPartially addresses #7367.Screenshot
Testing the changes
Included a unit test. Without the fix in this PR, the test fails:
With this fix, the test passes.
Changelog
Check List
yarn test:jest
yarn test:jest_integration