diff --git a/all_test.go b/all_test.go index dd8ae18..a024173 100644 --- a/all_test.go +++ b/all_test.go @@ -257,6 +257,9 @@ var libraryTable = []struct { // Whitespace handling. {" / descendant-or-self :: node() // child :: book / child :: * [ contains( . , '083' ) ] ", "0836217462"}, + + // Equals-off-by-one. + {"library/book[isbn='083621746']", exists(false)}, } var libraryXml = []byte(` diff --git a/parser.go b/parser.go index 4b5c448..5ded228 100644 --- a/parser.go +++ b/parser.go @@ -104,7 +104,7 @@ func (node *Node) equals(s string) bool { for i := node.pos; i < node.end; i++ { if node.nodes[i].kind == textNode { for _, c := range node.nodes[i].text { - if si > len(s) { + if si >= len(s) { return false } if s[si] != c {