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;
|
xmlParserInputPtr ret = NULL;
|
||||||
xmlChar *URI;
|
xmlChar *URI;
|
||||||
const xmlChar *base = NULL;
|
const xmlChar *base = NULL;
|
||||||
|
int res;
|
||||||
|
|
||||||
if (ctx == NULL) return(NULL);
|
if (ctx == NULL) return(NULL);
|
||||||
if (ctxt->input != 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");
|
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (xmlBuildURISafe(systemId, base, &URI) < 0) {
|
res = xmlBuildURISafe(systemId, base, &URI);
|
||||||
xmlSAX2ErrMemory(ctxt);
|
if (URI == NULL) {
|
||||||
|
if (res < 0)
|
||||||
|
xmlSAX2ErrMemory(ctxt);
|
||||||
|
else
|
||||||
|
xmlWarnMsg(ctxt, XML_ERR_INVALID_URI,
|
||||||
|
"Can't resolve URI: %s\n", systemId);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
|
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) {
|
res = xmlBuildURISafe(systemId, (const xmlChar *) base, &URI);
|
||||||
xmlSAX2ErrMemory(ctxt);
|
|
||||||
return;
|
if (URI == NULL) {
|
||||||
}
|
if (res < 0) {
|
||||||
if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
|
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");
|
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
|
||||||
xmlFree(URI);
|
xmlFree(URI);
|
||||||
} else {
|
} 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
|
* @ID: the System ID for the entity to load
|
||||||
* @lst: the return value for the set of parsed nodes
|
* @lst: the return value for the set of parsed nodes
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Use xmlParseCtxtExternalEntity.
|
||||||
|
*
|
||||||
* Parse an external general entity
|
* Parse an external general entity
|
||||||
* An external general parsed entity is well-formed if it matches the
|
* An external general parsed entity is well-formed if it matches the
|
||||||
* production labeled extParsedEnt.
|
* production labeled extParsedEnt.
|
||||||
|
|||||||
@@ -1844,9 +1844,7 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
|
|||||||
input = xmlLoadExternalEntity((char *) ent->URI,
|
input = xmlLoadExternalEntity((char *) ent->URI,
|
||||||
(char *) ent->ExternalID, ctxt);
|
(char *) ent->ExternalID, ctxt);
|
||||||
} else {
|
} else {
|
||||||
input = xmlNewInputMemory(ctxt, NULL, "", 0, NULL,
|
return(NULL);
|
||||||
XML_INPUT_BUF_STATIC |
|
|
||||||
XML_INPUT_BUF_ZERO_TERMINATED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == NULL)
|
if (input == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user