json-path / JsonPath

Java JsonPath implementation
Apache License 2.0
8.88k stars 1.64k forks source link

Fix parsing logic of function parameters with closing parentheses #989

Open q2w opened 8 months ago

q2w commented 8 months ago

Currently a function with parameter which have parentheses is wrongly parsed. As soon as a closing parentheses is encountered, the parsing logic assumes end state for the function parameter. For example, given concat(sum(), 10) then sum( is treated as first parameter. This is wrong parsing logic.

A parameter should be treated completely parsed only when a , or, the last ) is encountered ( that is groupParen == 0)

q2w commented 8 months ago

@kallestenflo

Test Scenario: Json: {} Path: $.concat("Bob", $.concat(" Joe", " Alex"))

Before this change, this would result in the below error. Here the internal concat is not interpreted rightly because of this bug.

Arguments to function: 'concat' are not closed properly.
com.jayway.jsonpath.InvalidPathException: Arguments to function: 'concat' are not closed properly.
q2w commented 8 months ago

@kallestenflo