* xmlNoNetExternalEntityLoader: * @URL: the URL for the entity to load * @ID: the System ID for the entity to load * @ctxt: the context in which the entity is called or NULL * * A specific entity loader disabling network accesses, though still * allowing local catalog accesses for resolution. * * Returns a new allocated xmlParserInputPtr, or NULL. */
| 2156 | * Returns a new allocated xmlParserInputPtr, or NULL. |
| 2157 | */ |
| 2158 | xmlParserInputPtr |
| 2159 | xmlNoNetExternalEntityLoader(const char *URL, const char *ID, |
| 2160 | xmlParserCtxtPtr ctxt) { |
| 2161 | xmlParserInputPtr input = NULL; |
| 2162 | xmlChar *resource = NULL; |
| 2163 | |
| 2164 | #ifdef LIBXML_CATALOG_ENABLED |
| 2165 | resource = xmlResolveResourceFromCatalog(URL, ID, ctxt); |
| 2166 | #endif |
| 2167 | |
| 2168 | if (resource == NULL) |
| 2169 | resource = (xmlChar *) URL; |
| 2170 | |
| 2171 | if (resource != NULL) { |
| 2172 | if ((!xmlStrncasecmp(BAD_CAST resource, BAD_CAST "ftp://", 6)) || |
| 2173 | (!xmlStrncasecmp(BAD_CAST resource, BAD_CAST "http://", 7))) { |
| 2174 | xmlCtxtErrIO(ctxt, XML_IO_NETWORK_ATTEMPT, |
| 2175 | (const char *) resource); |
| 2176 | /* |
| 2177 | * Also forward the error directly to the global error |
| 2178 | * handler, which the XML::LibXML test suite expects. |
| 2179 | */ |
| 2180 | __xmlIOErr(XML_FROM_IO, XML_IO_NETWORK_ATTEMPT, |
| 2181 | (const char *) resource); |
| 2182 | if (resource != (xmlChar *) URL) |
| 2183 | xmlFree(resource); |
| 2184 | return(NULL); |
| 2185 | } |
| 2186 | } |
| 2187 | input = xmlDefaultExternalEntityLoader((const char *) resource, ID, ctxt); |
| 2188 | if (resource != (xmlChar *) URL) |
| 2189 | xmlFree(resource); |
| 2190 | return(input); |
| 2191 | } |
| 2192 | |
| 2193 | /* |
| 2194 | * This global has to die eventually |