diff --git a/parser.c b/parser.c index cb1f72cf..9e4518f7 100644 --- a/parser.c +++ b/parser.c @@ -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,