Commit 872fea94 authored by Nick Wellnhofer's avatar Nick Wellnhofer
Browse files

Get rid of "blanks wrapper" for parameter entities

Now that replacement of parameter entities goes exclusively through
xmlSkipBlankChars, we can account for the surrounding space characters
there and remove the "blanks wrapper" hack.
parent d9e43c7d
......@@ -2169,7 +2169,6 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
while (1) {
if (IS_BLANK_CH(CUR)) { /* CHECKED tstblanks.xml */
NEXT;
res++;
} else if (CUR == '%') {
/*
* Need to handle support of entities branching here
......@@ -2184,6 +2183,15 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
} else {
break;
}
/*
* Also increase the counter when entering or exiting a PERef.
* The spec says: "When a parameter-entity reference is recognized
* in the DTD and included, its replacement text MUST be enlarged
* by the attachment of one leading and one following space (#x20)
* character."
*/
res++;
}
}
return(res);
......@@ -2446,57 +2454,6 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
return(0);
}
/**
* xmlNewBlanksWrapperInputStream:
* @ctxt: an XML parser context
* @entity: an Entity pointer
*
* Create a new input stream for wrapping
* blanks around a PEReference
*
* Returns the new input stream or NULL
*/
static void deallocblankswrapper (xmlChar *str) {xmlFree(str);}
static xmlParserInputPtr
xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
xmlParserInputPtr input;
xmlChar *buffer;
size_t length;
if (entity == NULL) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlNewBlanksWrapperInputStream entity\n");
return(NULL);
}
if (xmlParserDebugEntities)
xmlGenericError(xmlGenericErrorContext,
"new blanks wrapper for entity: %s\n", entity->name);
input = xmlNewInputStream(ctxt);
if (input == NULL) {
return(NULL);
}
length = xmlStrlen(entity->name) + 5;
buffer = xmlMallocAtomic(length);
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
xmlFree(input);
return(NULL);
}
buffer [0] = ' ';
buffer [1] = '%';
buffer [length-3] = ';';
buffer [length-2] = ' ';
buffer [length-1] = 0;
memcpy(buffer + 2, entity->name, length - 5);
input->free = deallocblankswrapper;
input->base = buffer;
input->cur = buffer;
input->length = length;
input->end = &buffer[length];
return(input);
}
/**
* xmlParserHandlePEReference:
* @ctxt: the parser context
......@@ -7945,10 +7902,6 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
"Internal: %%%s; is not a parameter entity\n",
name, NULL);
} else if (ctxt->input->free != deallocblankswrapper) {
input = xmlNewBlanksWrapperInputStream(ctxt, entity);
if (xmlPushInput(ctxt, input) < 0)
return;
} else {
xmlChar start[4];
xmlCharEncoding enc;
......
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/errors/754946.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%SYSTEM;
^
%SYSTEM;
^
Entity: line 1:
A<lbbbbbbbbbbbbbbbbbbb_
^
......
Entity: line 1: parser error : Space required after '<!ENTITY'
%zz;
^
%zz;
^
Entity: line 1:
<!ENTITY<?xDOCTYPEm~?>
^
Entity: line 1: parser error : xmlParseEntityDecl: no name
%zz;
^
%zz;
^
Entity: line 1:
<!ENTITY<?xDOCTYPEm~?>
^
Entity: line 1: parser error : ParsePI: PI xDOCTYPEm space expected
%zz;
^
%zz;
^
Entity: line 1:
<!ENTITY<?xDOCTYPEm~?>
^
Entity: line 1: parser error : Space required after '<!ENTITY'
%zz;
^
Entity: line 3: parser error : Space required after '<!ENTITY'
%zz;<!ELEMENTD(%MENT%MENTDŹMENTD%zNMT9KENSMYSYSTEM;MENT9%zz;
^
Entity: line 1:
<!ENTITY<?xDOCTYPEm~?>
^
Entity: line 1: parser error : xmlParseEntityDecl: no name
%zz;
^
Entity: line 3: parser error : xmlParseEntityDecl: no name
%zz;<!ELEMENTD(%MENT%MENTDŹMENTD%zNMT9KENSMYSYSTEM;MENT9%zz;
^
Entity: line 1:
<!ENTITY<?xDOCTYPEm~?>
^
Entity: line 1: parser error : ParsePI: PI xDOCTYPEm space expected
%zz;
^
Entity: line 3: parser error : ParsePI: PI xDOCTYPEm space expected
%zz;<!ELEMENTD(%MENT%MENTDŹMENTD%zNMT9KENSMYSYSTEM;MENT9%zz;
^
Entity: line 1:
<!ENTITY<?xDOCTYPEm~?>
^
Entity: line 1: parser error : Space required after 'ELEMENT'
%xx;
^
./test/errors/759573-2.xml:6: parser error : Space required after 'ELEMENT'
%xx;ggKENSMYNT&#35;MENTD&#372zz;'>
^
Entity: line 3:
%zz;<!ELEMENTD(%MENT%MENTDŹMENTD%zNMT9KENSMYSYSTEM;MENT9%zz;
^
Entity: line 1: parser error : Content error in the external subset
%xx;
^
./test/errors/759573-2.xml:6: parser error : Content error in the external subset
%xx;ggKENSMYNT&#35;MENTD&#372zz;'>
^
Entity: line 3:
%zz;<!ELEMENTD(%MENT%MENTDŹMENTD%zNMT9KENSMYSYSTEM;MENT9%zz;
^
......
......@@ -7,15 +7,15 @@ LEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz
./test/errors/759573.xml:1: parser error : Entity value required
LEMENT t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz
^
Entity: line 1: parser error : PEReference: no name
%xx;
^
./test/errors/759573.xml:1: parser error : PEReference: no name
T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
^
Entity: line 1:
%<![INCLUDE[000%ஸ000%z;
^
Entity: line 1: parser error : Content error in the external subset
%xx;
^
./test/errors/759573.xml:1: parser error : Content error in the external subset
T t (A)><!ENTITY % xx '&#37;<![INCLUDE[000&#37;&#3000;000&#37;z;'><!ENTITYz>%xx;
^
Entity: line 1:
%<![INCLUDE[000%ஸ000%z;
^
......
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/errors10/781205.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%a;
^
%a;
^
Entity: line 1:
<:0000
^
......
test/valid/dtds/766956.dtd:2: parser error : PEReference: expecting ';'
%ä%ent;
^
Entity: line 1: parser error : Content error in the external subset
%ent;
^
test/valid/dtds/766956.dtd:2: parser error : Content error in the external subset
%ent;
^
Entity: line 1:
value
^
test/valid/dtds/766956.dtd:2: parser error : PEReference: expecting ';'
%ä%ent;
^
Entity: line 1: parser error : Content error in the external subset
%ent;
^
test/valid/dtds/766956.dtd:2: parser error : Content error in the external subset
%ent;
^
Entity: line 1:
value
^
......
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defroot;
^
%defroot; %defmiddle; %deftest;
^
Entity: line 1:
&lt;!ELEMENT root (middle) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defmiddle;
^
%defroot; %defmiddle; %deftest;
^
Entity: line 1:
&lt;!ELEMENT middle (test) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%deftest;
^
%defroot; %defmiddle; %deftest;
^
Entity: line 1:
&lt;!ELEMENT test (#PCDATA) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defroot;
^
%defroot; %defmiddle; %deftest;
^
Entity: line 1:
&lt;!ELEMENT root (middle) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defmiddle;
^
%defroot; %defmiddle; %deftest;
^
Entity: line 1:
&lt;!ELEMENT middle (test) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%deftest;
^
%defroot; %defmiddle; %deftest;
^
Entity: line 1:
&lt;!ELEMENT test (#PCDATA) >
^
......
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defroot;
^
%defroot;%defmiddle;%deftest;
^
Entity: line 1:
&lt;!ELEMENT root (middle) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defmiddle;
^
%defroot;%defmiddle;%deftest;
^
Entity: line 1:
&lt;!ELEMENT middle (test) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%deftest;
^
%defroot;%defmiddle;%deftest;
^
Entity: line 1:
&lt;!ELEMENT test (#PCDATA) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defroot;
^
%defroot;%defmiddle;%deftest;
^
Entity: line 1:
&lt;!ELEMENT root (middle) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%defmiddle;
^
%defroot;%defmiddle;%deftest;
^
Entity: line 1:
&lt;!ELEMENT middle (test) >
^
Entity: line 1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
%deftest;
^
%defroot;%defmiddle;%deftest;
^
Entity: line 1:
&lt;!ELEMENT test (#PCDATA) >
^
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment