1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 03:55:04 +03:00

xinclude: Fix fallback for text includes

Fixes #772.
This commit is contained in:
Nick Wellnhofer 2024-07-18 19:27:43 +02:00
parent 0dada8041a
commit 322e733b84
5 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<doc>
text not found
</doc>

View File

@ -0,0 +1 @@
I/O warning : failed to load "test/XInclude/docs/404.txt": No such file or directory

View File

@ -0,0 +1,7 @@
0 1 doc 0 0
1 14 #text 0 1
1 3 #text 0 1 text not found
1 14 #text 0 1
0 15 doc 0 0

View File

@ -0,0 +1,7 @@
<?xml version="1.0"?>
<doc>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="404.txt" parse="text">
<xi:fallback>text not found</xi:fallback>
</xi:include>
</doc>

View File

@ -1410,9 +1410,14 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
inputStream = xmlLoadResource(pctxt, (const char*) url, NULL,
XML_RESOURCE_XINCLUDE_TEXT);
if (inputStream == NULL) {
/*
* ENOENT only produces a warning which isn't reflected in errNo.
*/
if (pctxt->errNo == XML_ERR_NO_MEMORY)
xmlXIncludeErrMemory(ctxt);
else
else if ((pctxt->errNo != XML_ERR_OK) &&
(pctxt->errNo != XML_IO_ENOENT) &&
(pctxt->errNo != XML_IO_UNKNOWN))
xmlXIncludeErr(ctxt, NULL, pctxt->errNo, "load error", NULL);
goto error;
}