diff --git a/parser.c b/parser.c index 7d3f4715..20fedfa3 100644 --- a/parser.c +++ b/parser.c @@ -8238,7 +8238,10 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) { */ SKIP(9); - SKIP_BLANKS; + if (SKIP_BLANKS == 0) { + xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, + "Space required after 'DOCTYPE'\n"); + } /* * Parse the DOCTYPE name. @@ -8272,20 +8275,9 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) { (!ctxt->disableSAX)) ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI); - /* - * Is there any internal subset declarations ? - * they are handled separately in xmlParseInternalSubset() - */ - if (RAW == '[') - return; - - /* - * We should be at the end of the DOCTYPE declaration. - */ - if (RAW != '>') { + if ((RAW != '[') && (RAW != '>')) { xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL); } - NEXT; } /** @@ -10782,7 +10774,9 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) { xmlParseDocTypeDecl(ctxt); if (RAW == '[') { xmlParseInternalSubset(ctxt); - } + } else if (RAW == '>') { + NEXT; + } /* * Create and update the external subset. @@ -11508,6 +11502,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) { if (RAW == '[') { ctxt->instate = XML_PARSER_DTD; } else { + if (RAW == '>') + NEXT; /* * Create and update the external subset. */ diff --git a/result/errors/759573.xml.ent b/result/errors/759573.xml.ent index 3c6be9a8..46f12d75 100644 --- a/result/errors/759573.xml.ent +++ b/result/errors/759573.xml.ent @@ -1,3 +1,6 @@ +./test/errors/759573.xml:1: parser error : Space required after 'DOCTYPE' +%xx; ^ -Entity: line 1: -%%xx; ^ -Entity: line 1: -%%xx; ^ -Entity: line 1: -%%xx; ^ -Entity: line 1: -%%xx; - ^ -Entity: line 1: -%%xx; - ^ -Entity: line 1: -%[]> + ^ diff --git a/result/errors/doctype1.xml.err b/result/errors/doctype1.xml.err new file mode 100644 index 00000000..71283ea2 --- /dev/null +++ b/result/errors/doctype1.xml.err @@ -0,0 +1,3 @@ +./test/errors/doctype1.xml:1: parser error : Start tag expected, '<' not found +[]> + ^ diff --git a/result/errors/doctype1.xml.str b/result/errors/doctype1.xml.str new file mode 100644 index 00000000..5e63269b --- /dev/null +++ b/result/errors/doctype1.xml.str @@ -0,0 +1,4 @@ +./test/errors/doctype1.xml:1: parser error : Start tag expected, '<' not found +[]> + ^ +./test/errors/doctype1.xml : failed to parse diff --git a/result/errors/doctype2.xml.ent b/result/errors/doctype2.xml.ent new file mode 100644 index 00000000..ddb4f563 --- /dev/null +++ b/result/errors/doctype2.xml.ent @@ -0,0 +1,3 @@ +./test/errors/doctype2.xml:1: parser error : Space required after 'DOCTYPE' + + ^ diff --git a/result/errors/doctype2.xml.err b/result/errors/doctype2.xml.err new file mode 100644 index 00000000..ddb4f563 --- /dev/null +++ b/result/errors/doctype2.xml.err @@ -0,0 +1,3 @@ +./test/errors/doctype2.xml:1: parser error : Space required after 'DOCTYPE' + + ^ diff --git a/result/errors/doctype2.xml.str b/result/errors/doctype2.xml.str new file mode 100644 index 00000000..1e7f4c2b --- /dev/null +++ b/result/errors/doctype2.xml.str @@ -0,0 +1,4 @@ +./test/errors/doctype2.xml:1: parser error : Space required after 'DOCTYPE' + + ^ +./test/errors/doctype2.xml : failed to parse diff --git a/test/errors/doctype1.xml b/test/errors/doctype1.xml new file mode 100644 index 00000000..25ac8e6d --- /dev/null +++ b/test/errors/doctype1.xml @@ -0,0 +1,2 @@ +[]> + diff --git a/test/errors/doctype2.xml b/test/errors/doctype2.xml new file mode 100644 index 00000000..0ee04064 --- /dev/null +++ b/test/errors/doctype2.xml @@ -0,0 +1,2 @@ + +