File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 99- Add ` .inner_html ` property. Allows to get and set inner HTML of a node.
1010- Update various docstrings.
1111- Optimize performance for` css_first ` in lexbor backend
12+ - Fix segfaults when accessing attributes. Resolves #135 .
1213
1314## Version 0.3.34
1415
Original file line number Diff line number Diff line change @@ -343,6 +343,9 @@ cdef class LexborNode:
343343 cdef size_t str_len = 0
344344 attributes = dict ()
345345
346+ if self .node.type != LXB_DOM_NODE_TYPE_ELEMENT:
347+ return attributes
348+
346349 while attr != NULL :
347350 key = lxb_dom_attr_local_name_noi(attr, & str_len)
348351 value = lxb_dom_attr_value_noi(attr, & str_len)
Original file line number Diff line number Diff line change @@ -18,3 +18,14 @@ def test_sets_inner_html():
1818 parser .css_first ("#main" ).inner_html = "<span>Test</span>"
1919 actual = parser .css_first ("#main" ).inner_html
2020 assert actual == expected
21+
22+
23+ def test_checking_attributes_does_not_segfault ():
24+ parser = LexborHTMLParser ("" )
25+ root_node = parser .root
26+ assert root_node is not None
27+ for node in root_node .traverse ():
28+ print (node .parent )
29+ parent = node .parent
30+ assert parent is not None
31+ parent = parent .attributes .get ("anything" )
You can’t perform that action at this time.
0 commit comments