From 4d59e22a19c6c88cd37d7c5fc3d570d2ac6f21c6 Mon Sep 17 00:00:00 2001 From: "William M. Brack" Date: Mon, 8 Mar 2004 14:42:31 +0000 Subject: [PATCH] enhanced to assure that if xpointer is called for a document, the * xinclude.c: enhanced to assure that if xpointer is called for a document, the XML_PARSE_NOENT flag is set before parsing the included document so that entities will automatically get taken care of. * xpointer.c: corrected code so that, if an XML_ENTITY_REF node is encountered, it will log it and not crash (bug 135713) --- ChangeLog | 9 +++++++++ xinclude.c | 18 ++++++++++++++++++ xpointer.c | 13 ++++++++----- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d2dbc34..11cb097d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Mon Mar 8 22:33:14 HKT 2004 William Brack + + * xinclude.c: enhanced to assure that if xpointer is called + for a document, the XML_PARSE_NOENT flag is set before parsing + the included document so that entities will automatically get + taken care of. + * xpointer.c: corrected code so that, if an XML_ENTITY_REF node + is encountered, it will log it and not crash (bug 135713) + Sun Mar 7 19:03:48 HKT 2004 William Brack * xinclude.c: modified to make sub-includes inherit the diff --git a/xinclude.c b/xinclude.c index 629c8504..3cf1f547 100644 --- a/xinclude.c +++ b/xinclude.c @@ -1361,6 +1361,9 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { xmlChar *URL; xmlChar *fragment = NULL; int i = 0; +#ifdef LIBXML_XPTR_ENABLED + int saveFlags; +#endif #ifdef DEBUG_XINCLUDE xmlGenericError(xmlGenericErrorContext, "Loading doc %s:%d\n", url, nr); @@ -1425,7 +1428,22 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) { #ifdef DEBUG_XINCLUDE printf("loading %s\n", URL); #endif +#ifdef LIBXML_XPTR_ENABLED + /* + * If this is an XPointer evaluation, we want to assure that + * all entities have been resolved prior to processing the + * referenced document + */ + saveFlags = ctxt->parseFlags; + if (fragment != NULL) { /* if this is an XPointer eval */ + ctxt->parseFlags |= XML_PARSE_NOENT; + } +#endif + doc = xmlXIncludeParseFile(ctxt, (const char *)URL); +#ifdef LIBXML_XPTR_ENABLED + ctxt->parseFlags = saveFlags; +#endif if (doc == NULL) { xmlFree(URL); if (fragment != NULL) diff --git a/xpointer.c b/xpointer.c index de098249..7f014de6 100644 --- a/xpointer.c +++ b/xpointer.c @@ -2308,6 +2308,7 @@ next: (*level)++; goto found; } +skip: /* This label should only be needed if something is wrong! */ if (cur->next != NULL) { cur = cur->next; goto found; @@ -2328,11 +2329,13 @@ found: (cur->type != XML_TEXT_NODE) && (cur->type != XML_DOCUMENT_NODE) && (cur->type != XML_HTML_DOCUMENT_NODE) && - (cur->type != XML_CDATA_SECTION_NODE)) - goto next; - if (cur->type == XML_ENTITY_REF_NODE) { - TODO - } + (cur->type != XML_CDATA_SECTION_NODE)) { + if (cur->type == XML_ENTITY_REF_NODE) { /* Shouldn't happen */ + TODO + goto skip; + } + goto next; + } return(cur); }