diff --git a/parse.go b/parse.go index 5b44cd8..5393125 100644 --- a/parse.go +++ b/parse.go @@ -868,20 +868,18 @@ func (s *scanner) scanNumber() float64 { func (s *scanner) scanString() string { var ( - c = 0 end = s.curr ) s.nextChar() i := s.pos - s.currSize - if s.currSize > 1 { - c++ - } + c := s.currSize for s.curr != end { if !s.nextChar() { panic(errors.New("xpath: scanString got unclosed string")) } c += s.currSize } + c -= 1 s.nextChar() return s.text[i : i+c] } diff --git a/xpath_expression_test.go b/xpath_expression_test.go index d6ccee1..77f24ea 100644 --- a/xpath_expression_test.go +++ b/xpath_expression_test.go @@ -155,3 +155,12 @@ func TestBUG_104(t *testing.T) { test_xpath_count(t, book_example, `//author[1]`, 4) test_xpath_values(t, book_example, `//author[1]/text()`, "Giada De Laurentiis", "J K. Rowling", "James McGovern", "Erik T. Ray") } + +func TestNonEnglishPredicateExpression(t *testing.T) { + // https://github.com/antchfx/xpath/issues/106 + doc := createNode("", RootNode) + n := doc.createChildNode("h1", ElementNode) + n.addAttribute("id", "断点") + n.createChildNode("Hello,World!", TextNode) + test_xpath_count(t, doc, "//h1[@id='断点']", 1) +}