-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: give the tokenizer the ability to reject unclosed items
- Loading branch information
1 parent
78078e4
commit 7a50e2d
Showing
3 changed files
with
21 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,18 @@ func TestParserPropertyNameExtension(t *testing.T) { | |
enabled: false, | ||
valid: false, | ||
}, | ||
{ | ||
name: "Missing closing a filter expression shouldn't crash", | ||
input: "$.paths.*.*[?([email protected])", | ||
enabled: false, | ||
valid: false, | ||
}, | ||
{ | ||
name: "Missing closing a array crash", | ||
input: "$.paths.*[?@[\"x-my-ignore\"]", | ||
enabled: false, | ||
valid: false, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,7 +413,7 @@ func TestTokenizer_categorize(t *testing.T) { | |
{name: "dot child with malformed array subscript", path: "$.child[1:2:3:4]"}, | ||
{name: "dot child with array subscript with zero step", path: "$.child[1:2:0]"}, | ||
{name: "dot child with non-integer array subscript", path: "$.child[1:2:a]"}, | ||
{name: "dot child with unclosed array subscript", path: "$.child[*"}, | ||
{name: "dot child with unclosed array subscript", path: "$.child[*", illegal: true}, | ||
{name: "dot child with missing array subscript", path: "$.child[]", simple: true}, | ||
{name: "dot child with embedded space", path: "$.child more", simple: true}, | ||
{name: "bracket child", path: "$['child']", simple: true}, | ||
|
@@ -429,7 +429,7 @@ func TestTokenizer_categorize(t *testing.T) { | |
{name: "bracket child with array subscript", path: "$['child'][*]"}, | ||
{name: "bracket child with malformed array subscript", path: "$['child'][1:2:3:4]"}, | ||
{name: "bracket child with non-integer array subscript", path: "$['child'][1:2:a]"}, | ||
{name: "bracket child with unclosed array subscript", path: "$['child'][*"}, | ||
{name: "bracket child with unclosed array subscript", path: "$['child'][*", illegal: true}, | ||
{name: "bracket child with missing array subscript", path: "$['child'][]", simple: true}, | ||
{name: "bracket child followed by space", path: "$['child'] ", illegal: true}, | ||
{name: "bracket dotted child", path: "$['child1.child2']", simple: true}, | ||
|
@@ -497,7 +497,7 @@ func TestTokenizer_categorize(t *testing.T) { | |
{name: "simple filter with bracket with extra whitespace", path: "$[?( ( @.child ) )]"}, | ||
{name: "simple filter with more complex subpath", path: "$[?((@.child[0]))]"}, | ||
{name: "missing filter ", path: "$[?()]"}, | ||
{name: "unclosed filter", path: "$[?("}, | ||
{name: "unclosed filter", path: "$[?(", illegal: true}, | ||
{name: "filter with missing operator", path: "$[?(@.child @.other)]"}, | ||
{name: "filter with malformed term", path: "$[?([)]", illegal: true}, | ||
{name: "filter with misplaced open bracket", path: "$[?(@.child ()]", illegal: true}, | ||
|
@@ -564,13 +564,13 @@ func TestTokenizer_categorize(t *testing.T) { | |
{name: "filter conjunction", path: "$[?(@.child&&@.other)]"}, | ||
{name: "filter conjunction with literals and whitespace", path: "$[?(@.child == 'x' && -9 == @.other)]"}, | ||
{name: "filter conjunction with bracket children", path: "$[?(@['child'][*]&&@['other'])]"}, | ||
{name: "filter invalid leading conjunction", path: "$[?(&&"}, | ||
{name: "filter invalid leading conjunction", path: "$[?(&&", illegal: true}, | ||
{name: "filter conjunction with extra whitespace", path: "$[?(@.child && @.other)]"}, | ||
{name: "filter disjunction", path: "$[?(@.child||@.other)]"}, | ||
{name: "filter invalid leading disjunction", path: "$[?(||"}, | ||
{name: "filter invalid leading disjunction", path: "$[?(||", illegal: true}, | ||
{name: "filter disjunction with extra whitespace", path: "$[?(@.child || @.other)]"}, | ||
{name: "simple filter of child", path: "$.child[?(@.child)]"}, | ||
{name: "filter with missing end", path: "$[?(@.child"}, | ||
{name: "filter with missing end", path: "$[?(@.child", illegal: true}, | ||
{name: "nested filter (edge case)", path: "$[?(@.y[?(@.z)])]"}, | ||
{name: "filter negation", path: "$[?([email protected])]"}, | ||
{name: "filter negation of comparison (edge case)", path: "$[?([email protected]>1)]"}, | ||
|