mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
parser: Don't report error on invalid URI
Only fragment identifiers are an error. This removes the last user of xmlErrMsg*. Now every error reported by the parser should result in one of ctxt->wellFormed, ctxt->nsWellFormed or ctxt->valid being set to zero.
This commit is contained in:
55
parser.c
55
parser.c
@@ -349,23 +349,6 @@ xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|||||||
val, NULL, NULL, 0, msg, val);
|
val, NULL, NULL, 0, msg, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlErrMsgStr:
|
|
||||||
* @ctxt: an XML parser context
|
|
||||||
* @error: the error number
|
|
||||||
* @msg: the error message
|
|
||||||
* @val: a string value
|
|
||||||
*
|
|
||||||
* Handle a non fatal parser error
|
|
||||||
*/
|
|
||||||
static void LIBXML_ATTR_FORMAT(3,0)
|
|
||||||
xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|
||||||
const char *msg, const xmlChar * val)
|
|
||||||
{
|
|
||||||
xmlCtxtErr(ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_ERROR,
|
|
||||||
val, NULL, NULL, 0, msg, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlNsErr:
|
* xmlNsErr:
|
||||||
* @ctxt: an XML parser context
|
* @ctxt: an XML parser context
|
||||||
@@ -5735,23 +5718,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
|||||||
xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL);
|
xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL);
|
||||||
}
|
}
|
||||||
if (URI) {
|
if (URI) {
|
||||||
xmlURIPtr uri;
|
if (xmlStrchr(URI, '#')) {
|
||||||
|
|
||||||
if (xmlParseURISafe((const char *) URI, &uri) < 0) {
|
|
||||||
xmlErrMemory(ctxt);
|
|
||||||
} else if (uri == NULL) {
|
|
||||||
/*
|
|
||||||
* This really ought to be a well formedness error
|
|
||||||
* but the XML Core WG decided otherwise c.f. issue
|
|
||||||
* E26 of the XML erratas.
|
|
||||||
*/
|
|
||||||
xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
|
|
||||||
"Invalid URI: %s\n", URI);
|
|
||||||
} else if (uri->fragment != NULL) {
|
|
||||||
/*
|
|
||||||
* Okay this is foolish to block those but not
|
|
||||||
* invalid URIs.
|
|
||||||
*/
|
|
||||||
xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL);
|
xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL);
|
||||||
} else {
|
} else {
|
||||||
if ((ctxt->sax != NULL) &&
|
if ((ctxt->sax != NULL) &&
|
||||||
@@ -5761,7 +5728,6 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
|||||||
XML_EXTERNAL_PARAMETER_ENTITY,
|
XML_EXTERNAL_PARAMETER_ENTITY,
|
||||||
literal, URI, NULL);
|
literal, URI, NULL);
|
||||||
}
|
}
|
||||||
xmlFreeURI(uri);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -5803,26 +5769,9 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
|||||||
xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL);
|
xmlFatalErr(ctxt, XML_ERR_VALUE_REQUIRED, NULL);
|
||||||
}
|
}
|
||||||
if (URI) {
|
if (URI) {
|
||||||
xmlURIPtr uri;
|
if (xmlStrchr(URI, '#')) {
|
||||||
|
|
||||||
if (xmlParseURISafe((const char *) URI, &uri) < 0) {
|
|
||||||
xmlErrMemory(ctxt);
|
|
||||||
} else if (uri == NULL) {
|
|
||||||
/*
|
|
||||||
* This really ought to be a well formedness error
|
|
||||||
* but the XML Core WG decided otherwise c.f. issue
|
|
||||||
* E26 of the XML erratas.
|
|
||||||
*/
|
|
||||||
xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
|
|
||||||
"Invalid URI: %s\n", URI);
|
|
||||||
} else if (uri->fragment != NULL) {
|
|
||||||
/*
|
|
||||||
* Okay this is foolish to block those but not
|
|
||||||
* invalid URIs.
|
|
||||||
*/
|
|
||||||
xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL);
|
xmlFatalErr(ctxt, XML_ERR_URI_FRAGMENT, NULL);
|
||||||
}
|
}
|
||||||
xmlFreeURI(uri);
|
|
||||||
}
|
}
|
||||||
if ((RAW != '>') && (SKIP_BLANKS_PE == 0)) {
|
if ((RAW != '>') && (SKIP_BLANKS_PE == 0)) {
|
||||||
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
|
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
|
||||||
|
|||||||
Reference in New Issue
Block a user