Skip to content

fix: keep escape sequences that would break the JSON when decoded - #8

Open
zignd-hc wants to merge 1 commit into
usebruno:mainfrom
zignd-hc:fix/preserve-json-breaking-unicode-escapes
Open

fix: keep escape sequences that would break the JSON when decoded#8
zignd-hc wants to merge 1 commit into
usebruno:mainfrom
zignd-hc:fix/preserve-json-breaking-unicode-escapes

Conversation

@zignd-hc

@zignd-hc zignd-hc commented Aug 13, 2026

Copy link
Copy Markdown

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

image

After

image

02 Issue usebruno/bruno#7954 minimal

Before

image

After

image

03 Backslash and control chars

Before

image

After

image

04 Regression - Unicode still decodes

Before

image

After

image

\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
zignd-hc force-pushed the fix/preserve-json-breaking-unicode-escapes branch from 3a64c21 to 8ee7044 Compare August 13, 2026 19:38
@zignd-hc

zignd-hc commented Aug 14, 2026

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant