diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-08-22 16:30:37 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-08-22 16:30:37 +0000 |
commit | dc2cee29d094958139f409e30209f68953c9cb67 (patch) | |
tree | 503a8265440554315d7a10c2a11baf59ca54e25f /xmlIO.c | |
parent | 5d90b6c983185e09dd514aa48d7df51b8a236466 (diff) | |
download | android_external_libxml2-dc2cee29d094958139f409e30209f68953c9cb67.tar.gz android_external_libxml2-dc2cee29d094958139f409e30209f68953c9cb67.tar.bz2 android_external_libxml2-dc2cee29d094958139f409e30209f68953c9cb67.zip |
Added the part about section 7.2 on URI resolution, fixed a side effect in
* include/libxml/catalog.h catalog.c xmlIO.c HTMLparser.c:
Added the part about section 7.2 on URI resolution,
fixed a side effect in the HTML parser, look complete
and ready to rock except the URI/SystemID part!
Daniel
Diffstat (limited to 'xmlIO.c')
-rw-r--r-- | xmlIO.c | 42 |
1 files changed, 32 insertions, 10 deletions
@@ -2384,7 +2384,7 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID, #ifdef LIBXML_CATALOG_ENABLED /* * If the resource doesn't exists as a file, - * try to load it from the resource pointed in the catalog + * try to load it from the resource pointed in the catalogs */ pref = xmlCatalogGetDefaults(); @@ -2404,21 +2404,43 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID, (const xmlChar *)URL); } /* - * Do a global lookup + * Try a global lookup */ - if (((resource == NULL) -#ifdef HAVE_STAT - || (stat((const char *) resource, &info) < 0) -#endif - ) && ((pref == XML_CATA_ALLOW_ALL) || - (pref == XML_CATA_ALLOW_GLOBAL))) { - + if ((resource == NULL) && + ((pref == XML_CATA_ALLOW_ALL) || + (pref == XML_CATA_ALLOW_GLOBAL))) { resource = xmlCatalogResolve((const xmlChar *)ID, (const xmlChar *)URL); } + if ((resource == NULL) && (URL != NULL)) + resource = xmlStrdup(URL); + /* * TODO: do an URI lookup on the reference */ + if ((resource != NULL) +#ifdef HAVE_STAT + && (stat((const char *) resource, &info) < 0) +#endif + ) { + xmlChar *tmp = NULL; + + if ((ctxt->catalogs != NULL) && + ((pref == XML_CATA_ALLOW_ALL) || + (pref == XML_CATA_ALLOW_DOCUMENT))) { + tmp = xmlCatalogLocalResolveURI(ctxt->catalogs, resource); + } + if ((tmp == NULL) && + (pref == XML_CATA_ALLOW_ALL) || + (pref == XML_CATA_ALLOW_GLOBAL)) { + tmp = xmlCatalogResolveURI(resource); + } + + if (tmp != NULL) { + xmlFree(resource); + resource = tmp; + } + } } #endif @@ -2445,7 +2467,7 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID, ctxt->sax->warning(ctxt, "failed to load external entity \"%s\"\n", resource); } - if (resource != (xmlChar *) URL) + if ((resource != NULL) && (resource != (xmlChar *) URL)) xmlFree(resource); return(ret); } |