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

Cannot parse un-scoped property names. #11

Open
mhemesath opened this issue Jun 20, 2011 · 3 comments
Open

Cannot parse un-scoped property names. #11

mhemesath opened this issue Jun 20, 2011 · 3 comments

Comments

@mhemesath
Copy link
Contributor

I stumbled upon this from a bad input name in my EJS. It seems that querystring isn't expecting un-scoped properties. I don't know what should happen in this case, but the error should probably be handled somehow?

require("qs").parse("[foo]=bar")
TypeError: Cannot read property 'undefined' of undefined
    at parse (/node_modules/qs/lib/querystring.js:50:37)
    at /node_modules/qs/lib/querystring.js:73:9
    at Array.reduce (native)
    at Object.parse (/node_modules/qs/lib/querystring.js:27:6)
    at [object Context]:1:15
    at Interface.<anonymous> (repl.js:171:22)
    at Interface.emit (events.js:64:17)
    at Interface._onLine (readline.js:153:10)
    at Interface._line (readline.js:408:8)
    at Interface._ttyWrite (readline.js:585:14)
@tj
Copy link
Owner

tj commented Jun 20, 2011

woah, yeah not sure what that would be, { foo: 'bar' } still?

@mhemesath
Copy link
Contributor Author

Yeah, that or { '[foo]': 'bar' }.

I don't think it matters too much though, as I doubt anyone is going to intentionally do this. I vote for consistency and just bind the foo property directly to the req.body with the bar value. If this behavior is unexpected, they will quickly see whats going on when they inspect the request anyway.

@tj
Copy link
Owner

tj commented Jun 20, 2011

the error message definitely sucks, that's the worst part

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

2 participants