Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Python JSONPath RFC 9535 Change Log

## Version 0.1.2 (unreleased)

**Fixes**

- Handle end of query when lexing inside a filter expression.

## Version 0.1.1

Fix PyPi classifiers and README.
Expand Down
6 changes: 5 additions & 1 deletion jsonpath_rfc9535/lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ def lex_inside_filter(l: Lexer) -> Optional[StateFn]: # noqa: D103, PLR0915, PL
l.ignore_whitespace()
c = l.next()

if c in ("", "]"):
if c == "":
l.error("unclosed bracketed selection")
return None

if c == "]":
l.filter_depth -= 1
if len(l.paren_stack) == 1:
l.error("unbalanced parentheses")
Expand Down
7 changes: 7 additions & 0 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def test_unclosed_selection_list(env: JSONPathEnvironment) -> None:
env.compile("$[1,2")


def test_unclosed_selection_list_inside_filter(env: JSONPathEnvironment) -> None:
with pytest.raises(
JSONPathSyntaxError, match=r"unclosed bracketed selection, line 1, column 10"
):
env.compile("$[?@.a < 1")


def test_function_missing_param(env: JSONPathEnvironment) -> None:
with pytest.raises(JSONPathTypeError):
env.compile("$[?(length()==1)]")
Expand Down