Skip to content

Commit 8f714b3

Browse files
committed
Fix unicode selectors.
Resolves #184.
1 parent 9ed5a75 commit 8f714b3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# selectolax Changelog
22

3+
Unreleased
4+
5+
- Fix CSS selectors that contain Unicode characters.
36

47
# Version 0.4.0
58

selectolax/lexbor/selection.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ cdef class LexborCSSSelector:
5353
raise TypeError("Query must be a string.")
5454

5555
bytes_query = query.encode(_ENCODING)
56-
selectors_list = lxb_css_selectors_parse(self.parser, <lxb_char_t *> bytes_query, <size_t>len(query))
56+
selectors_list = lxb_css_selectors_parse(self.parser, <lxb_char_t *> bytes_query, <size_t>len(bytes_query))
5757

5858
if selectors_list == NULL:
5959
raise SelectolaxError("Can't parse CSS selector.")

tests/test_lexbor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ def test_double_unwrap_does_not_segfault():
5050
inner_div.unwrap()
5151
some_set.add(outer_div.parent)
5252
some_set.add(outer_div.parent)
53+
54+
55+
def test_unicode_selector_works():
56+
html = '<span data-original-title="Pneu renforcé"></span>'
57+
tree = LexborHTMLParser(html)
58+
node = tree.css_first('span[data-original-title="Pneu renforcé"]')
59+
assert node.tag == "span"

0 commit comments

Comments
 (0)