Commit a3f1e3e5 authored by Daniel Veillard's avatar Daniel Veillard

Avoid extra processing on entities

If an entity has already been checked for correctness no
need to check it on every reference
parent a0989068
......@@ -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);
}
......
......@@ -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);
......
......@@ -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)
......
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment