auth0/node-odata-parser

Bug in $format Parsing

Opened this issue · 1 comments

I noticed that if the $format parameter is present, it doesn't respect any potential following parameters:

console.log(oData.parse('$select=foo,bar&$top=10&$format=application/json&$skip=42'));

{
  '$select': [ 'foo', 'bar' ],
  '$top': 10,
  '$format': 'application/json&$skip=42'
}

Note how $skip is not parsed and is instead concatenated to $format.

However, if I move $skip to precede $format everything is parsed as expected:

console.log(oData.parse('$select=foo,bar&$top=10&$skip=42&$format=application/json'));

{
  '$select': [ 'foo', 'bar' ],
  '$top': 10,
  '$skip': 42,
  '$format': 'application/json'
}

Interesting. Definitely a bug with the grammar. It probably wouldn't be too hard to update the grammar so that "&" is recognized as not part of the $format string. Ideally, we'd limit that to a specific set of characters that are allowed in the format string. (odata.pegjs, near 221.)