Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing logic of function parameters with closing parentheses #989

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

q2w
Copy link

@q2w q2w commented Jan 21, 2024

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)

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 q2w marked this pull request as ready for review January 21, 2024 16:11
@q2w
Copy link
Author

q2w commented Jan 23, 2024

@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.

…t to another function

Add test for fixing parsing login when path has a function as argument to another function
@q2w
Copy link
Author

q2w commented Feb 5, 2024

@kallestenflo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant