From d85245f9349db5766c9fedfa8c933de236330a7b Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 16 Jan 2022 21:39:04 +0100 Subject: [PATCH] Fix regression with PEs in external DTD Fix a regression introduced with commit a28f7d87. In some cases, parameter entity references in external DTDs wouldn't be expanded. Fixes #306. --- parser.c | 3 ++- result/valid/pe-test.xml | 3 +++ result/valid/pe-test.xml.err | 0 result/valid/pe-test.xml.err.rdr | 0 test/valid/dtds/pe-test.dtd | 3 +++ test/valid/pe-test.xml | 2 ++ 6 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 result/valid/pe-test.xml create mode 100644 result/valid/pe-test.xml.err create mode 100644 result/valid/pe-test.xml.err.rdr create mode 100644 test/valid/dtds/pe-test.dtd create mode 100644 test/valid/pe-test.xml diff --git a/parser.c b/parser.c index 2f7ac112..7796cb51 100644 --- a/parser.c +++ b/parser.c @@ -2194,7 +2194,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) { * It's Okay to use CUR/NEXT here since all the blanks are on * the ASCII range. */ - if (ctxt->instate != XML_PARSER_DTD) { + if (((ctxt->inputNr == 1) && (ctxt->instate != XML_PARSER_DTD)) || + (ctxt->instate == XML_PARSER_START)) { const xmlChar *cur; /* * if we are in the document content, go really fast diff --git a/result/valid/pe-test.xml b/result/valid/pe-test.xml new file mode 100644 index 00000000..b7ccbcf2 --- /dev/null +++ b/result/valid/pe-test.xml @@ -0,0 +1,3 @@ + + +&ent; diff --git a/result/valid/pe-test.xml.err b/result/valid/pe-test.xml.err new file mode 100644 index 00000000..e69de29b diff --git a/result/valid/pe-test.xml.err.rdr b/result/valid/pe-test.xml.err.rdr new file mode 100644 index 00000000..e69de29b diff --git a/test/valid/dtds/pe-test.dtd b/test/valid/dtds/pe-test.dtd new file mode 100644 index 00000000..3715755e --- /dev/null +++ b/test/valid/dtds/pe-test.dtd @@ -0,0 +1,3 @@ + + + diff --git a/test/valid/pe-test.xml b/test/valid/pe-test.xml new file mode 100644 index 00000000..14946667 --- /dev/null +++ b/test/valid/pe-test.xml @@ -0,0 +1,2 @@ + +&ent;