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

Fix JsonParser not able to parse "\u0000" #1160

Merged
merged 1 commit into from May 8, 2022

Conversation

Genteure
Copy link
Contributor

@Genteure Genteure commented May 7, 2022

Currently JSON.parse does not handle \u0000 correctly:

var engine = new Engine();
engine.SetValue("log", new Action<object>(Console.WriteLine));
engine.Execute(@"js code below");
const null_text = '{"a":"\\u0000"}';
const null_obj = JSON.parse(null_text);
log(null_text);
log(null_obj.a.length);
log(null_obj.a);

const a_text = '{"a":"\\u0061"}';
const a_obj = JSON.parse(a_text);
log(a_text);
log(a_obj.a.length);
log(a_obj.a);

Expected output:

{"a":"\u0000"}
1

{"a":"\u0061"}
1
a

Current output:

{"a":"\u0000"}
5
u0000
{"a":"\u0061"}
1
a

This PR removed unneeded check for escaped characters, and added tests to verify escaped characters are correctly parsed.

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.

Looks good, thank you!

@lahma lahma merged commit 7276b49 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