From 871c6a36f3222fcbca452dec9fa0af216c715918 Mon Sep 17 00:00:00 2001 From: Will Roden Date: Thu, 14 Sep 2023 09:23:22 -0500 Subject: [PATCH] guard against invalid range when value is "'" --- path.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/path.go b/path.go index e7a3c724..72554bd8 100644 --- a/path.go +++ b/path.go @@ -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() { @@ -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] } }