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

JSON.parse in body parser fails silently when string has unescaped double quotes #20

Open
rahulreddy opened this issue Oct 1, 2015 · 0 comments

Comments

@rahulreddy
Copy link

I ran into this issue when using a route to upload a file NSR was stripping out double quotes after parsing the body into request.post. After digging through, I found out that JSON.parse returns a string with the quotes stripped (it should either throw an error or return an object) even though the input is just a string. Please try the code below in console to replicate the error.

var str = '"hello"';
console.log(JSON.parse(str));
// returns hello removing the quotes

var str = '"hello';
console.log(JSON.parse(str));
// throws SynraxError exception as it should
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

No branches or pull requests

1 participant