diff --git a/SAX2.c b/SAX2.c index b8011fec5..267a5fb39 100644 --- a/SAX2.c +++ b/SAX2.c @@ -406,6 +406,7 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId xmlParserInputPtr ret = NULL; xmlChar *URI; const xmlChar *base = NULL; + int res; if (ctx == NULL) return(NULL); if (ctxt->input != NULL) @@ -416,8 +417,13 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long"); return(NULL); } - if (xmlBuildURISafe(systemId, base, &URI) < 0) { - xmlSAX2ErrMemory(ctxt); + res = xmlBuildURISafe(systemId, base, &URI); + if (URI == NULL) { + if (res < 0) + xmlSAX2ErrMemory(ctxt); + else + xmlWarnMsg(ctxt, XML_ERR_INVALID_URI, + "Can't resolve URI: %s\n", systemId); return(NULL); } if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) { @@ -568,11 +574,16 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, } } - if (xmlBuildURISafe(systemId, (const xmlChar *) base, &URI) < 0) { - xmlSAX2ErrMemory(ctxt); - return; - } - if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) { + res = xmlBuildURISafe(systemId, (const xmlChar *) base, &URI); + + if (URI == NULL) { + if (res < 0) { + xmlSAX2ErrMemory(ctxt); + } else { + xmlWarnMsg(ctxt, XML_ERR_INVALID_URI, + "Can't resolve URI: %s\n", systemId); + } + } else if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) { xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long"); xmlFree(URI); } else { diff --git a/parser.c b/parser.c index 1a235af3d..ea475951f 100644 --- a/parser.c +++ b/parser.c @@ -12168,6 +12168,8 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctxt, const xmlChar *URL, * @ID: the System ID for the entity to load * @lst: the return value for the set of parsed nodes * + * DEPRECATED: Use xmlParseCtxtExternalEntity. + * * Parse an external general entity * An external general parsed entity is well-formed if it matches the * production labeled extParsedEnt. diff --git a/parserInternals.c b/parserInternals.c index fa6911039..39d0007df 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -1844,9 +1844,7 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) { input = xmlLoadExternalEntity((char *) ent->URI, (char *) ent->ExternalID, ctxt); } else { - input = xmlNewInputMemory(ctxt, NULL, "", 0, NULL, - XML_INPUT_BUF_STATIC | - XML_INPUT_BUF_ZERO_TERMINATED); + return(NULL); } if (input == NULL)