Repository navigation
fix: escape caught error messages in safe mode - #81
Open
RealBhupesh wants to merge 3 commits into
Open
RealBhupesh wants to merge 3 commits into
RealBhupesh wants to merge 3 commits into
Conversation
Use the existing JSON string escaping helper for caught errors. Assisted-by: LLM
Remove editor auto-indentation from the final brace. Assisted-by: LLM
Cover quotes, newlines, backslashes, NUL and lone surrogates across compact, indented and replacer modes. Assisted-by: LLM
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.
With
safe: true, an error thrown by a getter is converted to a string result.makeSafecurrently adds quote characters around that result without escaping the message, so quotes, newlines or control characters can produce invalid JSON.This uses the existing
strEscapehelper for the caught-error result. The change preserves the current root error-string behavior; it does not switch to per-property recovery or change unsafe mode.Added 35 regression assertions for quotes, newlines, backslashes, NUL and a lone surrogate. They cover compact output, indentation and an array replacer, with a function-replacer control. Running the new test on the original source fails at the first malformed quoted message, including a
JSON.parseerror.Validation on current main
bdd585fplus this patch:npm test: 84,326 passed, 1 skipped, including Standard lint.npm run tsc: passed.No dependency, option or API changes. AI assistance is recorded in the commit trailers.