mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-30 05:49:22 +03:00
Fix copying of entities in xmlParseReference
Before, reader mode would end up in a branch that didn't handle entities with multiple children and failed to update ent->last, so the hack copying the "extra" reader data wouldn't trigger. Consequently, some empty nodes in entities are correctly detected now in the test suite. (The detection of empty nodes in entities is still buggy, though.)
This commit is contained in:
28
parser.c
28
parser.c
@ -7159,17 +7159,23 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
|||||||
(ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY))&&
|
(ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY))&&
|
||||||
(ent->children == NULL)) {
|
(ent->children == NULL)) {
|
||||||
ent->children = list;
|
ent->children = list;
|
||||||
if (ctxt->replaceEntities) {
|
|
||||||
/*
|
/*
|
||||||
* Prune it directly in the generated document
|
* Prune it directly in the generated document
|
||||||
* except for single text nodes.
|
* except for single text nodes.
|
||||||
*/
|
*/
|
||||||
if (((list->type == XML_TEXT_NODE) &&
|
if ((ctxt->replaceEntities == 0) ||
|
||||||
(list->next == NULL)) ||
|
(ctxt->parseMode == XML_PARSE_READER) ||
|
||||||
(ctxt->parseMode == XML_PARSE_READER)) {
|
((list->type == XML_TEXT_NODE) &&
|
||||||
list->parent = (xmlNodePtr) ent;
|
(list->next == NULL))) {
|
||||||
list = NULL;
|
|
||||||
ent->owner = 1;
|
ent->owner = 1;
|
||||||
|
while (list != NULL) {
|
||||||
|
list->parent = (xmlNodePtr) ent;
|
||||||
|
xmlSetTreeDoc(list, ent->doc);
|
||||||
|
if (list->next == NULL)
|
||||||
|
ent->last = list;
|
||||||
|
list = list->next;
|
||||||
|
}
|
||||||
|
list = NULL;
|
||||||
} else {
|
} else {
|
||||||
ent->owner = 0;
|
ent->owner = 0;
|
||||||
while (list != NULL) {
|
while (list != NULL) {
|
||||||
@ -7185,16 +7191,6 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
|||||||
xmlAddEntityReference(ent, list, NULL);
|
xmlAddEntityReference(ent, list, NULL);
|
||||||
#endif /* LIBXML_LEGACY_ENABLED */
|
#endif /* LIBXML_LEGACY_ENABLED */
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
ent->owner = 1;
|
|
||||||
while (list != NULL) {
|
|
||||||
list->parent = (xmlNodePtr) ent;
|
|
||||||
xmlSetTreeDoc(list, ent->doc);
|
|
||||||
if (list->next == NULL)
|
|
||||||
ent->last = list;
|
|
||||||
list = list->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
xmlFreeNodeList(list);
|
xmlFreeNodeList(list);
|
||||||
list = NULL;
|
list = NULL;
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
1 1 test 1 0
|
1 1 test 1 0
|
||||||
1 14 #text 0 1
|
1 14 #text 0 1
|
||||||
|
|
||||||
1 1 test 0 0
|
1 1 test 1 0
|
||||||
1 15 test 0 0
|
|
||||||
1 14 #text 0 1
|
1 14 #text 0 1
|
||||||
|
|
||||||
0 15 x 0 0
|
0 15 x 0 0
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
2 1 c 0 0
|
2 1 c 0 0
|
||||||
2 15 c 0 0
|
2 15 c 0 0
|
||||||
2 3 #text 0 1 ,
|
2 3 #text 0 1 ,
|
||||||
2 1 d 0 0
|
2 1 d 1 0
|
||||||
2 15 d 0 0
|
|
||||||
1 15 ent 0 0
|
1 15 ent 0 0
|
||||||
1 14 #text 0 1
|
1 14 #text 0 1
|
||||||
|
|
||||||
@ -292,8 +291,7 @@
|
|||||||
2 1 c 0 0
|
2 1 c 0 0
|
||||||
2 15 c 0 0
|
2 15 c 0 0
|
||||||
2 3 #text 0 1 ,
|
2 3 #text 0 1 ,
|
||||||
2 1 d 0 0
|
2 1 d 1 0
|
||||||
2 15 d 0 0
|
|
||||||
1 15 ent 0 0
|
1 15 ent 0 0
|
||||||
1 14 #text 0 1
|
1 14 #text 0 1
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user