Skip to content

Commit

Permalink
guard against invalid range when value is "'"
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Sep 14, 2023
1 parent 0b817d2 commit 871c6a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func newSelectorNode(selector string) *selectorNode {

func (n *selectorNode) filter(node ast.Node) (ast.Node, error) {
selector := n.selector
if len(selector) > 0 && selector[0] == '\'' && selector[len(selector)-1] == '\'' {
if len(selector) > 1 && selector[0] == '\'' && selector[len(selector)-1] == '\'' {
selector = selector[1 : len(selector)-1]
}
switch node.Type() {
Expand All @@ -517,7 +517,7 @@ func (n *selectorNode) filter(node ast.Node) (ast.Node, error) {
return nil, errors.Wrapf(err, "failed to unquote")
}
case '\'':
if key[len(key)-1] == '\'' {
if len(key) > 1 && key[len(key)-1] == '\'' {
key = key[1 : len(key)-1]
}
}
Expand Down

0 comments on commit 871c6a3

Please sign in to comment.