Skip to content

Commit 38e4e4e

Browse files
committed
Catch too many colons in slice selectors.
1 parent ea6da90 commit 38e4e4e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Raise a `JSONPathSyntaxError` for unescaped whitespace and control characters.
2121
- Raise a `JSONPathSyntaxError` for empty selector segments.
2222
- Raise a `JSONPathIndexError` if an index selector is out of range.
23+
- Raise a `JSONPathSyntaxError` for too many colons in a slice selector.
2324

2425
## Version 0.4.0
2526

jsonpath/parse.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,15 @@ def parse_selector_list(self, stream: TokenStream) -> ListSelector:
371371
)
372372
elif stream.current.kind == TOKEN_SLICE_START:
373373
list_items.append(self.parse_slice(stream))
374-
elif stream.current.kind == TOKEN_EOF:
374+
375+
if stream.peek.kind == TOKEN_EOF:
375376
raise JSONPathSyntaxError(
376377
"unexpected end of selector list",
377378
token=stream.current,
378379
)
379380

380381
if stream.peek.kind != TOKEN_RBRACKET:
382+
stream.expect_peek(TOKEN_COMMA)
381383
stream.next_token()
382384

383385
stream.next_token()

0 commit comments

Comments
 (0)