diff options
Diffstat (limited to 'third_party/libxml/xinclude.c')
-rw-r--r-- | third_party/libxml/xinclude.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/third_party/libxml/xinclude.c b/third_party/libxml/xinclude.c index 31ea026..bb41180 100644 --- a/third_party/libxml/xinclude.c +++ b/third_party/libxml/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) { @@ -617,6 +613,19 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) { } /* + * 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 */ if ((!local) && (xml == 1)) { |