Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Cannot parse un-scoped property names. #11

Open
mhemesath opened this Issue · 3 comments

2 participants

@mhemesath

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
Owner
tj commented

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

@mhemesath

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
Owner
tj commented

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
Something went wrong with that request. Please try again.