1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-26 00:37:43 +03:00

584220 xpointer(/) and xinclude problems

* xinclude.c: xpointer(/) in xinclude could lead to sub-document nodes
  and also fixed the code to inherit the dictionary from the embedding
  document
This commit is contained in:
Daniel Veillard
2009-08-25 19:24:15 +02:00
parent 283d50279d
commit cb6f525fff

View File

@@ -438,8 +438,8 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
* try to ensure that new documents included are actually * try to ensure that new documents included are actually
* built with the same dictionary as the including document. * built with the same dictionary as the including document.
*/ */
if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL) && if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL)) {
(pctxt->dict != NULL)) { if (pctxt->dict != NULL)
xmlDictFree(pctxt->dict); xmlDictFree(pctxt->dict);
pctxt->dict = ctxt->doc->dict; pctxt->dict = ctxt->doc->dict;
xmlDictReference(pctxt->dict); xmlDictReference(pctxt->dict);
@@ -798,6 +798,10 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
* * * *
************************************************************************/ ************************************************************************/
static xmlNodePtr
xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
xmlDocPtr source, xmlNodePtr elem);
/** /**
* xmlXIncludeCopyNode: * xmlXIncludeCopyNode:
* @ctxt: the XInclude context * @ctxt: the XInclude context
@@ -818,6 +822,9 @@ xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
return(NULL); return(NULL);
if (elem->type == XML_DTD_NODE) if (elem->type == XML_DTD_NODE)
return(NULL); return(NULL);
if (elem->type == XML_DOCUMENT_NODE)
result = xmlXIncludeCopyNodeList(ctxt, target, source, elem->children);
else
result = xmlDocCopyNode(elem, target, 1); result = xmlDocCopyNode(elem, target, 1);
return(result); return(result);
} }