mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
parser: Support encoded external PEs in entity values
Corner case which was never supported.
This commit is contained in:
parent
8afd321abd
commit
0ba22c0513
28
parser.c
28
parser.c
@ -8183,7 +8183,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
|
||||
*/
|
||||
static int
|
||||
xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
xmlParserInputPtr input = NULL;
|
||||
xmlParserInputPtr oldinput, input = NULL;
|
||||
xmlChar *content = NULL;
|
||||
size_t length, i;
|
||||
int ret = -1;
|
||||
@ -8210,6 +8210,32 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
xmlBufResetInput(input->buf->buffer, input);
|
||||
|
||||
oldinput = ctxt->input;
|
||||
ctxt->input = input;
|
||||
|
||||
xmlDetectEncoding(ctxt);
|
||||
|
||||
/*
|
||||
* Parse a possible text declaration first
|
||||
*/
|
||||
if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
|
||||
xmlParseTextDecl(ctxt);
|
||||
/*
|
||||
* An XML-1.0 document can't reference an entity not XML-1.0
|
||||
*/
|
||||
if ((xmlStrEqual(ctxt->version, BAD_CAST "1.0")) &&
|
||||
(!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH,
|
||||
"Version mismatch between document and entity\n");
|
||||
}
|
||||
}
|
||||
|
||||
ctxt->input = oldinput;
|
||||
|
||||
xmlBufShrink(input->buf->buffer, input->cur - input->base);
|
||||
|
||||
while ((res = xmlParserInputBufferGrow(input->buf, 16384)) > 0)
|
||||
;
|
||||
|
||||
|
3
result/valid/pe-val-latin1.xml
Normal file
3
result/valid/pe-val-latin1.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc SYSTEM "dtds/pe-val-latin1.dtd">
|
||||
<doc>&latin1;</doc>
|
3
test/valid/dtds/pe-val-latin1.dtd
Normal file
3
test/valid/dtds/pe-val-latin1.dtd
Normal file
@ -0,0 +1,3 @@
|
||||
<!ELEMENT doc (#PCDATA)>
|
||||
<!ENTITY % pe SYSTEM "pe-val-latin1.ent">
|
||||
<!ENTITY latin1 "%pe;">
|
2
test/valid/dtds/pe-val-latin1.ent
Normal file
2
test/valid/dtds/pe-val-latin1.ent
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
äöü
|
2
test/valid/pe-val-latin1.xml
Normal file
2
test/valid/pe-val-latin1.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<!DOCTYPE doc SYSTEM "dtds/pe-val-latin1.dtd">
|
||||
<doc>&latin1;</doc>
|
Loading…
x
Reference in New Issue
Block a user