Skip to content

Crash on malformed query arguments  #4

@Mickael-van-der-Beek

Description

@Mickael-van-der-Beek

The library crashes when a querystring contains a value without a key or an empty key.

e.g:

url.parse('http://www.google.com/hello?=test', true)

will crash with the error:

TypeError: Cannot call method 'push' of null
    at QueryStringParser$placeValue [as placeValue] (/node_modules/querystringparser/js/querystringparser.js:267:23)
    at QueryStringParser$parseString [as parseString] /node_modules/querystringparser/js/querystringparser.js:373:26)
    at Function.QueryStringParser$Parse [as parse] (/node_modules/querystringparser/js/querystringparser.js:51:23)
    at Url$parse [as parse] (/node_modules/fast-url-parser/src/urlparser.js:107:38)
    at Function.Url$Parse [as parse] (/node_modules/fast-url-parser/src/urlparser.js:892:9)
    at repl:1:6
    at REPLServer.self.eval (repl.js:110:21)
    at Interface.<anonymous> (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)

In comparison Node.js (v0.10.29 for me), will return:

{ protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'www.google.com',
  port: null,
  hostname: 'www.google.com',
  hash: null,
  search: '?=test',
  query: { '': 'test' },
  pathname: '/hello',
  path: '/hello?=test',
  href: 'http://www.google.com/hello?=test' }

and considers that the key is an empty string ''.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions