mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
Don't try to handle namespaces when building HTML documents
Don't try to resolve namespace in xmlSAX2StartElement when parsing HTML documents. This useless operation could slow down the parser considerably. Found by OSS-Fuzz.
This commit is contained in:
12
SAX2.c
12
SAX2.c
@@ -1663,12 +1663,13 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctxt->html) {
|
||||
/*
|
||||
* Insert all the defaulted attributes from the DTD especially namespaces
|
||||
* Insert all the defaulted attributes from the DTD especially
|
||||
* namespaces
|
||||
*/
|
||||
if ((!ctxt->html) &&
|
||||
((ctxt->myDoc->intSubset != NULL) ||
|
||||
(ctxt->myDoc->extSubset != NULL))) {
|
||||
if ((ctxt->myDoc->intSubset != NULL) ||
|
||||
(ctxt->myDoc->extSubset != NULL)) {
|
||||
xmlCheckDefaultedAttributes(ctxt, name, prefix, atts);
|
||||
}
|
||||
|
||||
@@ -1679,7 +1680,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
i = 0;
|
||||
att = atts[i++];
|
||||
value = atts[i++];
|
||||
if (!ctxt->html) {
|
||||
while ((att != NULL) && (value != NULL)) {
|
||||
if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l') &&
|
||||
(att[3] == 'n') && (att[4] == 's'))
|
||||
@@ -1689,7 +1689,6 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
value = atts[i++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Search the namespace, note that since the attributes have been
|
||||
@@ -1712,6 +1711,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
||||
if ((ns != NULL) && (ns->href != NULL) &&
|
||||
((ns->href[0] != 0) || (ns->prefix != NULL)))
|
||||
xmlSetNs(ret, ns);
|
||||
}
|
||||
|
||||
/*
|
||||
* process all the other attributes
|
||||
|
||||
Reference in New Issue
Block a user