1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-04-24 18:50:07 +03:00

parser: Remove useless ent->etype test in xmlParseReference

If ent->etype is invalid, ret can't equal XML_ERR_OK.
This commit is contained in:
Nick Wellnhofer 2022-12-20 03:09:11 +01:00
parent 7ee7f0360a
commit ec6633afae

View File

@ -7271,46 +7271,40 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
}
if ((ret == XML_ERR_OK) && (list != NULL)) {
if ((ent->etype == XML_INTERNAL_GENERAL_ENTITY) ||
(ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
ent->children = list;
/*
* Prune it directly in the generated document
* except for single text nodes.
*/
if ((ctxt->replaceEntities == 0) ||
(ctxt->parseMode == XML_PARSE_READER) ||
((list->type == XML_TEXT_NODE) &&
(list->next == NULL))) {
ent->owner = 1;
while (list != NULL) {
list->parent = (xmlNodePtr) ent;
if (list->doc != ent->doc)
xmlSetTreeDoc(list, ent->doc);
if (list->next == NULL)
ent->last = list;
list = list->next;
}
list = NULL;
} else {
ent->owner = 0;
while (list != NULL) {
list->parent = (xmlNodePtr) ctxt->node;
list->doc = ctxt->myDoc;
if (list->next == NULL)
ent->last = list;
list = list->next;
}
list = ent->children;
#ifdef LIBXML_LEGACY_ENABLED
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, list, NULL);
#endif /* LIBXML_LEGACY_ENABLED */
ent->children = list;
/*
* Prune it directly in the generated document
* except for single text nodes.
*/
if ((ctxt->replaceEntities == 0) ||
(ctxt->parseMode == XML_PARSE_READER) ||
((list->type == XML_TEXT_NODE) &&
(list->next == NULL))) {
ent->owner = 1;
while (list != NULL) {
list->parent = (xmlNodePtr) ent;
if (list->doc != ent->doc)
xmlSetTreeDoc(list, ent->doc);
if (list->next == NULL)
ent->last = list;
list = list->next;
}
} else {
xmlFreeNodeList(list);
list = NULL;
}
list = NULL;
} else {
ent->owner = 0;
while (list != NULL) {
list->parent = (xmlNodePtr) ctxt->node;
list->doc = ctxt->myDoc;
if (list->next == NULL)
ent->last = list;
list = list->next;
}
list = ent->children;
#ifdef LIBXML_LEGACY_ENABLED
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, list, NULL);
#endif /* LIBXML_LEGACY_ENABLED */
}
} else if ((ret != XML_ERR_OK) &&
(ret != XML_WAR_UNDECLARED_ENTITY)) {
xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,