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

Strict JSON validation failure could throw a SyntaxError for consistency with JSON.parse() #119

Closed
carlbennettnz opened this issue Aug 31, 2015 · 7 comments
Assignees
Labels

Comments

@carlbennettnz
Copy link

If my body is "bad" an Error is sent, but if my body is "{bad" a SyntaxError is sent.

@dougwilson
Copy link
Contributor

Hi! I'm unsure of what you are asking, unfortunately. We do throw a SyntaxError, at least with the most recent version. Can you elaborate more on the issue, provide a PR, provide a test case, or something else?

@dougwilson dougwilson self-assigned this Aug 31, 2015
@dougwilson
Copy link
Contributor

Oh, are you talking about https://github.com/expressjs/body-parser/blob/master/lib/types/json.js#L83 ? If so, we cannot change that to throw SyntaxError, as we used to, but not all JS platforms allow you to throw an instance of that error :(

@dougwilson
Copy link
Contributor

Well, I think in 2.0, we can make this change, since we'll just say we're not going to support those platforms any longer!

@carlbennettnz
Copy link
Author

Awesome 👍

@dougwilson
Copy link
Contributor

I'm reclassifying this as a bug and releasing in the 1.x series :) Please test out the fix on the master branch and let me know if it matches your expectations.

@carlbennettnz
Copy link
Author

Thanks, that works perfectly :)

@dougwilson
Copy link
Contributor

This as been published to npm as 1.14.0

@expressjs expressjs locked and limited conversation to collaborators Sep 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants