Add an HTML parser option to avoid a default doctype
- include/libxml/HTMLparser.h: defines the new HTML parser option
HTML_PARSE_NODEFDTD
- HTMLparser.c: if option is set don't add a default DTD
- xmllint.c: add the corresponding --nodefdtd option in xmllint
diff --git a/HTMLparser.c b/HTMLparser.c
index 42dc776..224c65f 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -4670,7 +4670,7 @@
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
ctxt->sax->endDocument(ctxt->userData);
- if (ctxt->myDoc != NULL) {
+ if ((!(ctxt->options & HTML_PARSE_NODEFDTD)) && (ctxt->myDoc != NULL)) {
dtd = xmlGetIntSubset(ctxt->myDoc);
if (dtd == NULL)
ctxt->myDoc->intSubset =
@@ -6530,6 +6530,10 @@
ctxt->options |= XML_PARSE_HUGE;
options -= XML_PARSE_HUGE;
}
+ if (options & HTML_PARSE_NODEFDTD) {
+ ctxt->options |= HTML_PARSE_NODEFDTD;
+ options -= HTML_PARSE_NODEFDTD;
+ }
ctxt->dictNames = 0;
return (options);
}