diff --git a/SAX2.c b/SAX2.c index 3eea39aa3fcc3ebc1f794ff069ea8dbb22bbd91e..ce7a5d6b66fc6c76ef6dc04185a598d337292bc6 100644 --- a/SAX2.c +++ b/SAX2.c @@ -591,6 +591,7 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name) * parse the external entity */ xmlNodePtr children; + unsigned long oldnbent = ctxt->nbentities; val = xmlParseCtxtExternalEntity(ctxt, ret->URI, ret->ExternalID, &children); @@ -603,8 +604,9 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name) return(NULL); } ret->owner = 1; - if (ret->checked == 0) - ret->checked = 1; + if (ret->checked == 0) { + ret->checked = ctxt->nbentities - oldnbent + 1; + } } return(ret); } diff --git a/parser.c b/parser.c index ddf3b5bd40ac985b133f0049b6186a24ade017f1..362186be44a3c7b64519fbc854dbef25b3d7d920 100644 --- a/parser.c +++ b/parser.c @@ -4044,9 +4044,13 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { * entities problems */ if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && - (ent->content != NULL)) { + (ent->content != NULL) && (ent->checked == 0)) { + unsigned long oldnbent = ctxt->nbentities; + rep = xmlStringDecodeEntities(ctxt, ent->content, XML_SUBSTITUTE_REF, 0, 0, 0); + + ent->checked = ctxt->nbentities - oldnbent + 1; if (rep != NULL) { xmlFree(rep); rep = NULL; @@ -7213,7 +7217,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { * Store the number of entities needing parsing for this entity * content and do checkings */ - ent->checked = ctxt->nbentities - oldnbent; + ent->checked = ctxt->nbentities - oldnbent + 1; if (ret == XML_ERR_ENTITY_LOOP) { xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); xmlFreeNodeList(list); diff --git a/result/att11.sax b/result/att11.sax index 67dcf22ddaadd6029e8ea8a776c143a363ef7420..52d286162af64b1e85ae7729f076a22ba76e039f 100644 --- a/result/att11.sax +++ b/result/att11.sax @@ -12,9 +12,7 @@ SAX.externalSubset(attributes, , ) SAX.getEntity(ent) SAX.getEntity(recursive) SAX.getEntity(ent) -SAX.getEntity(recursive) SAX.getEntity(ent) -SAX.getEntity(recursive) SAX.startElement(attributes, nmtoken=' &ent; &ent; &ent; ', nmtokens=' Test this normalization ') SAX.endElement(attributes) diff --git a/result/att11.sax2 b/result/att11.sax2 index 859a9704bf6e37b940496695d4cac6ae7993437a..3e8cfd923f12d86d7d589ba6d85b7bea9a629c73 100644 --- a/result/att11.sax2 +++ b/result/att11.sax2 @@ -12,9 +12,7 @@ SAX.externalSubset(attributes, , ) SAX.getEntity(ent) SAX.getEntity(recursive) SAX.getEntity(ent) -SAX.getEntity(recursive) SAX.getEntity(ent) -SAX.getEntity(recursive) SAX.startElementNs(attributes, NULL, NULL, 0, 2, 0, nmtoken='&ent...', 17, nmtokens='Test...', 25) SAX.endElementNs(attributes, NULL, NULL) SAX.endDocument()