mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2026-01-26 21:41:34 +03:00
SAX2: Warn if URI resolution failed
This commit is contained in:
25
SAX2.c
25
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 {
|
||||
|
||||
2
parser.c
2
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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user