From 05bd1720ce9a71fee9307df816dcdccee7f5f0f5 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 1 Mar 2025 10:25:29 +0100 Subject: [PATCH] parser: Fix parsing of DTD content Regressed in 2.11. Fixes #868. --- parser.c | 6 +++++- result/errors/759573-2.xml.ent | 6 ++++++ result/errors/759573-2.xml.err | 6 ++++++ result/errors/759573-2.xml.str | 6 ++++++ result/errors/issue868.xml.ent | 3 +++ result/errors/issue868.xml.err | 3 +++ result/errors/issue868.xml.str | 4 ++++ test/errors/issue868.xml | 9 +++++++++ 8 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 result/errors/issue868.xml.ent create mode 100644 result/errors/issue868.xml.err create mode 100644 result/errors/issue868.xml.str create mode 100644 test/errors/issue868.xml diff --git a/parser.c b/parser.c index 8e66b1b6..a335980c 100644 --- a/parser.c +++ b/parser.c @@ -7234,7 +7234,11 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) { xmlParseComment(ctxt); break; default: - /* there is an error but it will be detected later */ + xmlFatalErr(ctxt, + ctxt->inSubset == 2 ? + XML_ERR_EXT_SUBSET_NOT_FINISHED : + XML_ERR_INT_SUBSET_NOT_FINISHED, + NULL); SKIP(2); break; } diff --git a/result/errors/759573-2.xml.ent b/result/errors/759573-2.xml.ent index ea2e421a..ea2726e1 100644 --- a/result/errors/759573-2.xml.ent +++ b/result/errors/759573-2.xml.ent @@ -20,5 +20,11 @@ Entity: line 1: %xx; ^ Entity: line 2: + +^ diff --git a/result/errors/issue868.xml.err b/result/errors/issue868.xml.err new file mode 100644 index 00000000..28ccc2c6 --- /dev/null +++ b/result/errors/issue868.xml.err @@ -0,0 +1,3 @@ +./test/errors/issue868.xml:3: parser error : Content error in the internal subset + +^ diff --git a/result/errors/issue868.xml.str b/result/errors/issue868.xml.str new file mode 100644 index 00000000..13f1e763 --- /dev/null +++ b/result/errors/issue868.xml.str @@ -0,0 +1,4 @@ +./test/errors/issue868.xml:3: parser error : Content error in the internal subset + +^ +./test/errors/issue868.xml : failed to parse diff --git a/test/errors/issue868.xml b/test/errors/issue868.xml new file mode 100644 index 00000000..e08ad3e7 --- /dev/null +++ b/test/errors/issue868.xml @@ -0,0 +1,9 @@ + + + + + +PP + +