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) ...@@ -591,6 +591,7 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
* parse the external entity * parse the external entity
*/ */
xmlNodePtr children; xmlNodePtr children;
unsigned long oldnbent = ctxt->nbentities;
val = xmlParseCtxtExternalEntity(ctxt, ret->URI, val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
ret->ExternalID, &children); ret->ExternalID, &children);
...@@ -603,8 +604,9 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name) ...@@ -603,8 +604,9 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
return(NULL); return(NULL);
} }
ret->owner = 1; ret->owner = 1;
if (ret->checked == 0) if (ret->checked == 0) {
ret->checked = 1; ret->checked = ctxt->nbentities - oldnbent + 1;
}
} }
return(ret); return(ret);
} }
......
...@@ -4044,9 +4044,13 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) { ...@@ -4044,9 +4044,13 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
* entities problems * entities problems
*/ */
if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) && 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, rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF, 0, 0, 0); XML_SUBSTITUTE_REF, 0, 0, 0);
ent->checked = ctxt->nbentities - oldnbent + 1;
if (rep != NULL) { if (rep != NULL) {
xmlFree(rep); xmlFree(rep);
rep = NULL; rep = NULL;
...@@ -7213,7 +7217,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { ...@@ -7213,7 +7217,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
* Store the number of entities needing parsing for this entity * Store the number of entities needing parsing for this entity
* content and do checkings * content and do checkings
*/ */
ent->checked = ctxt->nbentities - oldnbent; ent->checked = ctxt->nbentities - oldnbent + 1;
if (ret == XML_ERR_ENTITY_LOOP) { if (ret == XML_ERR_ENTITY_LOOP) {
xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL); xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
xmlFreeNodeList(list); xmlFreeNodeList(list);
......
...@@ -12,9 +12,7 @@ SAX.externalSubset(attributes, , ) ...@@ -12,9 +12,7 @@ SAX.externalSubset(attributes, , )
SAX.getEntity(ent) SAX.getEntity(ent)
SAX.getEntity(recursive) SAX.getEntity(recursive)
SAX.getEntity(ent) SAX.getEntity(ent)
SAX.getEntity(recursive)
SAX.getEntity(ent) SAX.getEntity(ent)
SAX.getEntity(recursive)
SAX.startElement(attributes, nmtoken=' &ent; &ent; &ent; ', nmtokens=' Test SAX.startElement(attributes, nmtoken=' &ent; &ent; &ent; ', nmtokens=' Test
this normalization ') this normalization ')
SAX.endElement(attributes) SAX.endElement(attributes)
......
...@@ -12,9 +12,7 @@ SAX.externalSubset(attributes, , ) ...@@ -12,9 +12,7 @@ SAX.externalSubset(attributes, , )
SAX.getEntity(ent) SAX.getEntity(ent)
SAX.getEntity(recursive) SAX.getEntity(recursive)
SAX.getEntity(ent) SAX.getEntity(ent)
SAX.getEntity(recursive)
SAX.getEntity(ent) SAX.getEntity(ent)
SAX.getEntity(recursive)
SAX.startElementNs(attributes, NULL, NULL, 0, 2, 0, nmtoken='&ent...', 17, nmtokens='Test...', 25) SAX.startElementNs(attributes, NULL, NULL, 0, 2, 0, nmtoken='&ent...', 17, nmtokens='Test...', 25)
SAX.endElementNs(attributes, NULL, NULL) SAX.endElementNs(attributes, NULL, NULL)
SAX.endDocument() 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