jsonpath icon indicating copy to clipboard operation
jsonpath copied to clipboard

Enable 'greedy' regex to capture entire script/filter expression

Open movitto opened this issue 5 years ago • 0 comments

Right now the following expression will trip up the parser:

$..[(')]')]

The parser will encounter the ')]' inside the static string and use that as the end of the script expression & child-member-component. When it encounters the closing single-quote a lexical error will be thrown.

This patch removes the '?' constraining the character wildcard in the script and filter expression matcher so that we completely parse expressions to the end. It also adds a test for this edge case.

Note: this causes issues with multiple filter expressions such as:

$..[?('expr1')][?('expr2')]

The parser will now pickup the expression as everything between the first '[?(' and the last ')]', in this case the expression will be:

'expr1')][?('expr2'

Which will throw the expression evaluator off.

At the current time it is not aparent how to handle both cases w/ the current BNF based parser.

movitto avatar Jun 17 '20 05:06 movitto