From 88f9c7ca80bfbc9a5429fc632b90d6c4a2a2787d Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 9 Apr 2008 10:33:41 +0200 Subject: Load /tmp/libxml2-2.6.32 into libxml2/branches/upstream/current. --- xinclude.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'xinclude.c') diff --git a/xinclude.c b/xinclude.c index 31ea026..bb41180 100644 --- a/xinclude.c +++ b/xinclude.c @@ -419,7 +419,6 @@ static xmlDocPtr xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) { xmlDocPtr ret; xmlParserCtxtPtr pctxt; - char *directory = NULL; xmlParserInputPtr inputStream; xmlInitParser(); @@ -456,10 +455,8 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) { inputPush(pctxt, inputStream); - if ((pctxt->directory == NULL) && (directory == NULL)) - directory = xmlParserGetDirectory(URL); - if ((pctxt->directory == NULL) && (directory != NULL)) - pctxt->directory = (char *) xmlStrdup((xmlChar *) directory); + if (pctxt->directory == NULL) + pctxt->directory = xmlParserGetDirectory(URL); pctxt->loadsubset |= XML_DETECT_IDS; @@ -516,9 +513,8 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */ if (href == NULL) return(-1); - local = 1; } - if (href[0] == '#') + if ((href[0] == '#') || (href[0] == 0)) local = 1; parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE); if (parse != NULL) { @@ -616,6 +612,19 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { return(-1); } + /* + * If local and xml then we need a fragment + */ + if ((local == 1) && (xml == 1) && + ((fragment == NULL) || (fragment[0] == 0))) { + xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION, + "detected a local recursion with no xpointer in %s\n", + URL); + if (fragment != NULL) + xmlFree(fragment); + return(-1); + } + /* * Check the URL against the stack for recursions */ -- cgit v1.2.3