Skip to content

Handle Unicode control characters in JSON strings - #7

Open
deonx03 wants to merge 2 commits into
usebruno:mainfrom
deonx03:main
Open

Handle Unicode control characters in JSON strings#7
deonx03 wants to merge 2 commits into
usebruno:mainfrom
deonx03:main

Conversation

@deonx03

@deonx03 deonx03 commented Aug 11, 2026

Copy link
Copy Markdown

Description

Bruno's JSON response preview decoded \u0022 escape sequences to a literal " but didn't re-escape it when rendering, producing output that looked like invalid JSON (e.g. "say "hello"") even though the underlying server response was valid.

This PR re-escapes embedded double quotes during rendering so the preview stays valid JSON.

Changes Made

  • decode-escaped-unicode.js: Re-escape double quotes produced by decoding \u0022, so the output stays valid JSON.
  • escaped.spec.js: Added test for adding escape when \u0022 is encountered

Fixes

#6

@deonx03

deonx03 commented Aug 12, 2026

Copy link
Copy Markdown
Author

Added safeUnicodeDecode to generalise the earlier quote-escaping fix into full JSON-safe output. Previously, decoding sequences like \u0008 or \u000a inserted raw control bytes (backspace, newline, etc.) into the output, producing invalid JSON. This now re-escapes all of JSON's mandatory escapes — ", \ , and the named control chars ( \b \f \n \r \t ) — and falls back to \uXXXX for any other control character (U+0000–U+001F).

AI used:

  • Claude Code

A feedback is welcome @helloanoop. (I am new to this Creating a pull request for a repo I don't own or control)

@deonx03 deonx03 changed the title fix: escape \u0022 to \" instead of a raw quote in JSON output Handle Unicode control characters in JSON strings Aug 13, 2026
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