mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-28 07:21:26 +03:00
Fix comparison of nodesets to strings
Fix two bugs in xmlXPathNodeValHash which could lead to errors when comparing nodesets to strings: - Only use contents of text nodes to compute the hash for element nodes. Comments, PIs, and other node types don't affect the string-value and must be ignored. - Reset `string` to NULL for node types other than text. Reported by Aleksei on the mailing list: https://mail.gnome.org/archives/xml/2017-September/msg00016.html
This commit is contained in:
parent
0c91391683
commit
5af594d8bc
13
result/XPath/tests/strbase
Normal file
13
result/XPath/tests/strbase
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
========================
|
||||
Expression: //p[.='abc']
|
||||
Object is a Node Set :
|
||||
Set contains 2 nodes:
|
||||
1 ELEMENT p
|
||||
ATTRIBUTE id
|
||||
TEXT
|
||||
content=1
|
||||
2 ELEMENT p
|
||||
ATTRIBUTE id
|
||||
TEXT
|
||||
content=2
|
@ -6,4 +6,6 @@
|
||||
<p><p>a span</p>n<p>ing one</p></p>
|
||||
<p><p>and an unbal</p><empty/>anced test</p>
|
||||
<p>for empty string <seq>123</seq></p>
|
||||
<p id="1">a<b>b</b>c</p>
|
||||
<p id="2"><!--X-->abc</p>
|
||||
</chapter>
|
||||
|
1
test/XPath/tests/strbase
Normal file
1
test/XPath/tests/strbase
Normal file
@ -0,0 +1 @@
|
||||
//p[.='abc']
|
6
xpath.c
6
xpath.c
@ -6400,16 +6400,12 @@ xmlXPathNodeValHash(xmlNodePtr node) {
|
||||
}
|
||||
while (tmp != NULL) {
|
||||
switch (tmp->type) {
|
||||
case XML_COMMENT_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
string = tmp->content;
|
||||
break;
|
||||
case XML_NAMESPACE_DECL:
|
||||
string = ((xmlNsPtr)tmp)->href;
|
||||
break;
|
||||
default:
|
||||
string = NULL;
|
||||
break;
|
||||
}
|
||||
if ((string != NULL) && (string[0] != 0)) {
|
||||
|
Loading…
Reference in New Issue
Block a user