diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-03-02 02:57:49 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-03-02 20:44:41 +0100 |
commit | bc06a522c10cbf491cfef4f82f169532e04044a1 (patch) | |
tree | e21e4b57de10b0649d17d20e399fff40634ff36e | |
parent | 78d7a5ca3c7ab3939d24cc86622e7ba702bdd678 (diff) | |
download | libxml2-bc06a522c10cbf491cfef4f82f169532e04044a1.tar.gz |
Fix recursion check in xinclude.c
Compare the included URL with the document's URL to detect local
inclusions.
Fixes #348.
-rw-r--r-- | result/XInclude/red.xml | 9 | ||||
-rw-r--r-- | result/XInclude/red.xml.rdr | 26 | ||||
-rw-r--r-- | test/XInclude/docs/red.xml | 10 | ||||
-rw-r--r-- | xinclude.c | 5 |
4 files changed, 48 insertions, 2 deletions
diff --git a/result/XInclude/red.xml b/result/XInclude/red.xml new file mode 100644 index 00000000..87adf844 --- /dev/null +++ b/result/XInclude/red.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xlink="http://www.w3.org/1999/xlink"> + <chapter> + <para xml:id="t100">Introduction</para> + </chapter> + <chapter> + <para xml:id="t100">Introduction</para> + </chapter> +</book> diff --git a/result/XInclude/red.xml.rdr b/result/XInclude/red.xml.rdr new file mode 100644 index 00000000..de332dbc --- /dev/null +++ b/result/XInclude/red.xml.rdr @@ -0,0 +1,26 @@ +0 1 book 0 0 +1 14 #text 0 1 + +1 1 chapter 0 0 +2 14 #text 0 1 + +2 1 para 0 0 +3 3 #text 0 1 Introduction +2 15 para 0 0 +2 14 #text 0 1 + +1 15 chapter 0 0 +1 14 #text 0 1 + +1 1 chapter 0 0 +2 14 #text 0 1 + +2 1 para 0 0 +3 3 #text 0 1 Introduction +2 15 para 0 0 +2 14 #text 0 1 + +1 15 chapter 0 0 +1 14 #text 0 1 + +0 15 book 0 0 diff --git a/test/XInclude/docs/red.xml b/test/XInclude/docs/red.xml new file mode 100644 index 00000000..75ee396d --- /dev/null +++ b/test/XInclude/docs/red.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<book xmlns:xi="http://www.w3.org/2001/XInclude" + xmlns:xlink="http://www.w3.org/1999/xlink"> + <chapter> + <para xml:id="t100">Introduction</para> + </chapter> + <chapter> + <xi:include href="./red.xml" xpointer="t100" parse="xml"/> + </chapter> +</book> @@ -525,8 +525,6 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { if (href == NULL) return(-1); } - if ((href[0] == '#') || (href[0] == 0)) - local = 1; parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); if (parse != NULL) { if (xmlStrEqual(parse, XINCLUDE_PARSE_XML)) @@ -623,6 +621,9 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { return(-1); } + if (xmlStrEqual(URL, ctxt->doc->URL)) + local = 1; + /* * If local and xml then we need a fragment */ |