Skip to content

Commit f7d323f

Browse files
committed
fix non-English characters query: #106, #99
1 parent b94a535 commit f7d323f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

parse.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,20 +868,18 @@ func (s *scanner) scanNumber() float64 {
868868

869869
func (s *scanner) scanString() string {
870870
var (
871-
c = 0
872871
end = s.curr
873872
)
874873
s.nextChar()
875874
i := s.pos - s.currSize
876-
if s.currSize > 1 {
877-
c++
878-
}
875+
c := s.currSize
879876
for s.curr != end {
880877
if !s.nextChar() {
881878
panic(errors.New("xpath: scanString got unclosed string"))
882879
}
883880
c += s.currSize
884881
}
882+
c -= 1
885883
s.nextChar()
886884
return s.text[i : i+c]
887885
}

xpath_expression_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,12 @@ func TestBUG_104(t *testing.T) {
155155
test_xpath_count(t, book_example, `//author[1]`, 4)
156156
test_xpath_values(t, book_example, `//author[1]/text()`, "Giada De Laurentiis", "J K. Rowling", "James McGovern", "Erik T. Ray")
157157
}
158+
159+
func TestNonEnglishPredicateExpression(t *testing.T) {
160+
// https://github.com/antchfx/xpath/issues/106
161+
doc := createNode("", RootNode)
162+
n := doc.createChildNode("h1", ElementNode)
163+
n.addAttribute("id", "断点")
164+
n.createChildNode("Hello,World!", TextNode)
165+
test_xpath_count(t, doc, "//h1[@id='断点']", 1)
166+
}

0 commit comments

Comments
 (0)