Skip to content
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

Make JsonParser escape character parsing more strict #1161

Merged
merged 1 commit into from May 8, 2022

Conversation

Genteure
Copy link
Contributor

@Genteure Genteure commented May 7, 2022

This is a continuation of #1160

This PR removes support for non-standard \v, \x00, \0123 and \(any char here), and will throw an error instead.

This behavior is matching other common JSON parser like JSON.parse found in nodejs.

// node v16.13.0
JSON.parse('{"\\v":1}')
// Uncaught SyntaxError: Unexpected token v in JSON at position 3
// Newtonsoft.Json 13.0.1
const string json = @"{""\v"":1}";
var obj1 = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
// Newtonsoft.Json.JsonReaderException: Bad JSON escape sequence: \v. Path '', line 1, position 4.

@lahma lahma force-pushed the strict-json-escaped-char branch from 5856511 to 2ba794d Compare May 8, 2022 05:45
Copy link
Collaborator

@lahma lahma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like when things get simpler!

@lahma lahma enabled auto-merge (squash) May 8, 2022 05:49
@lahma lahma merged commit b07562e into sebastienros:main May 8, 2022
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.

None yet

2 participants