fix: keep escape sequences that would break the JSON when decoded - #8
Open
zignd-hc wants to merge 1 commit into
Open
fix: keep escape sequences that would break the JSON when decoded#8zignd-hc wants to merge 1 commit into
zignd-hc wants to merge 1 commit into
Conversation
\uXXXX sequences were decoded unconditionally, so a value holding \u0022 gained a raw quote that terminated the string early and left the formatted output unparseable. Servers commonly emit those when embedding HTML in a field value. Quotes, backslashes and control characters are now re-emitted in escaped form, and unpaired surrogates are left escaped since they cannot be encoded as UTF-8. Two related issues go with it: the four hex digits are validated, where parseInt previously accepted a partial match such as \u12zz, and "\\" is consumed as a unit so a literal \u0022 in a value is no longer misread as an escape. Output now matches JSON.stringify(JSON.parse(input), null, 2) for any valid JSON input. Fixes usebruno/bruno#7954
zignd-hc
force-pushed
the
fix/preserve-json-breaking-unicode-escapes
branch
from
August 13, 2026 19:38
3a64c21 to
8ee7044
Compare
Author
|
Hey @helloanoop, I would appreciate if you could review this PR, it's related to this issue where you mentioned a PR here to fix it would be welcomed usebruno/bruno#7954 |
5 tasks
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.
Description
This PR aims to fix the issue reported in this Bruno issue: usebruno/bruno#7954
As the maintaininer @helloanoop suggested here in this comment, it would be better to fix the issue at the root cause which is here on fast-json-format, than implementing a workaround in Bruno.
Below I provide some screenshots of how it fixes the problem in Bruno, by simply pointing the latest Bruno main branch to this fast-json-format branch fix locally.
Test cases - Impact of the change in Bruno:
01 HTML in field value
Before
After
02 Issue usebruno/bruno#7954 minimal
Before
After
03 Backslash and control chars
Before
After
04 Regression - Unicode still decodes
Before
After