mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
parser: Convert some "internal errors" to meaningful codes
This commit is contained in:
parent
9912c36904
commit
e8fb3d639f
3
error.c
3
error.c
@ -1085,6 +1085,9 @@ xmlErrString(xmlParserErrors code) {
|
||||
case XML_ERR_CONDSEC_INVALID:
|
||||
errmsg = "XML conditional section '[' expected";
|
||||
break;
|
||||
case XML_ERR_INT_SUBSET_NOT_FINISHED:
|
||||
errmsg = "Content error in the internal subset";
|
||||
break;
|
||||
case XML_ERR_EXT_SUBSET_NOT_FINISHED:
|
||||
errmsg = "Content error in the external subset";
|
||||
break;
|
||||
|
@ -215,6 +215,7 @@ typedef enum {
|
||||
XML_ERR_ARGUMENT, /* 115 */
|
||||
XML_ERR_SYSTEM, /* 116 */
|
||||
XML_ERR_REDECL_PREDEF_ENTITY, /* 117 */
|
||||
XML_ERR_INT_SUBSET_NOT_FINISHED, /* 118 */
|
||||
XML_NS_ERR_XML_NAMESPACE = 200,
|
||||
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
|
||||
XML_NS_ERR_QNAME, /* 202 */
|
||||
|
28
parser.c
28
parser.c
@ -7889,18 +7889,15 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
|
||||
((entity->etype != XML_EXTERNAL_PARAMETER_ENTITY) &&
|
||||
(entity->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY)) ||
|
||||
(entity->content != NULL)) {
|
||||
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
xmlFatalErr(ctxt, XML_ERR_ARGUMENT,
|
||||
"xmlLoadEntityContent parameter error");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
input = xmlLoadExternalEntity((char *) entity->URI,
|
||||
(char *) entity->ExternalID, ctxt);
|
||||
if (input == NULL) {
|
||||
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlLoadEntityContent input error");
|
||||
if (input == NULL)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
oldinput = ctxt->input;
|
||||
oldinputNr = ctxt->inputNr;
|
||||
@ -8221,9 +8218,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
|
||||
} else if (RAW == '%') {
|
||||
xmlParsePEReference(ctxt);
|
||||
} else {
|
||||
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlParseInternalSubset: error detected in"
|
||||
" Markup declaration\n");
|
||||
xmlFatalErr(ctxt, XML_ERR_INT_SUBSET_NOT_FINISHED, NULL);
|
||||
xmlHaltParser(ctxt);
|
||||
return;
|
||||
}
|
||||
@ -8404,11 +8399,8 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
|
||||
((RAW != '/') || (NXT(1) != '>')) &&
|
||||
(IS_BYTE_CHAR(RAW))) && (PARSER_STOPPED(ctxt) == 0)) {
|
||||
attname = xmlParseAttribute(ctxt, &attvalue);
|
||||
if (attname == NULL) {
|
||||
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"xmlParseStartTag: problem parsing attributes\n");
|
||||
if (attname == NULL)
|
||||
break;
|
||||
}
|
||||
if (attvalue != NULL) {
|
||||
/*
|
||||
* [ WFC: Unique Att Spec ]
|
||||
@ -8939,14 +8931,13 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
|
||||
const xmlChar **atts = ctxt->atts;
|
||||
unsigned attrHashSize = 0;
|
||||
int maxatts = ctxt->maxatts;
|
||||
int nratts, nbatts, nbdef, inputid;
|
||||
int nratts, nbatts, nbdef;
|
||||
int i, j, nbNs, nbTotalDef, attval, nsIndex, maxAtts;
|
||||
int alloc = 0;
|
||||
|
||||
if (RAW != '<') return(NULL);
|
||||
NEXT1;
|
||||
|
||||
inputid = ctxt->input->id;
|
||||
nbatts = 0;
|
||||
nratts = 0;
|
||||
nbdef = 0;
|
||||
@ -9188,13 +9179,6 @@ next_attr:
|
||||
GROW;
|
||||
}
|
||||
|
||||
if (ctxt->input->id != inputid) {
|
||||
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||
"Unexpected change of input\n");
|
||||
localname = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Namespaces from default attributes
|
||||
*/
|
||||
@ -12282,7 +12266,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
|
||||
* check all input parameters, grab the document
|
||||
*/
|
||||
if ((lst == NULL) || (node == NULL) || (data == NULL) || (datalen < 0))
|
||||
return(XML_ERR_INTERNAL_ERROR);
|
||||
return(XML_ERR_ARGUMENT);
|
||||
switch (node->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
|
@ -63,8 +63,7 @@ Entity: line 1:
|
||||
^
|
||||
""".format(dir_prefix),
|
||||
't8':
|
||||
"""{0}/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
"""{0}/t8.xml:6: parser error : Content error in the internal subset
|
||||
%defroot; %defmiddle; %deftest;
|
||||
^
|
||||
Entity: line 1:
|
||||
@ -72,8 +71,7 @@ Entity: line 1:
|
||||
^
|
||||
""".format(dir_prefix),
|
||||
't8a':
|
||||
"""{0}/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
"""{0}/t8a.xml:6: parser error : Content error in the internal subset
|
||||
%defroot;%defmiddle;%deftest;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/errors/754946.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/754946.xml:3: parser error : Content error in the internal subset
|
||||
%SYSTEM;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/errors/754946.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/754946.xml:3: parser error : Content error in the internal subset
|
||||
%SYSTEM;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/errors/754946.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/754946.xml:3: parser error : Content error in the internal subset
|
||||
%SYSTEM;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -16,8 +16,7 @@ Entity: line 1: parser error : ParsePI: PI xDOCTYPEm space expected
|
||||
Entity: line 1:
|
||||
<!ENTITY<?xDOCTYPEm~?>
|
||||
^
|
||||
./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/759573-2.xml:6: parser error : Content error in the internal subset
|
||||
%xx;
|
||||
^
|
||||
Entity: line 2:
|
||||
|
@ -16,8 +16,7 @@ Entity: line 1: parser error : ParsePI: PI xDOCTYPEm space expected
|
||||
Entity: line 1:
|
||||
<!ENTITY<?xDOCTYPEm~?>
|
||||
^
|
||||
./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/759573-2.xml:6: parser error : Content error in the internal subset
|
||||
%xx;
|
||||
^
|
||||
Entity: line 2:
|
||||
|
@ -16,8 +16,7 @@ Entity: line 1: parser error : ParsePI: PI xDOCTYPEm space expected
|
||||
Entity: line 1:
|
||||
<!ENTITY<?xDOCTYPEm~?>
|
||||
^
|
||||
./test/errors/759573-2.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/759573-2.xml:6: parser error : Content error in the internal subset
|
||||
%xx;
|
||||
^
|
||||
Entity: line 2:
|
||||
|
@ -13,8 +13,7 @@ T t (A)><!ENTITY % xx '%<![INCLUDE[000%ஸ000%z;'><!ENTITYz>%xx;
|
||||
Entity: line 1:
|
||||
%<![INCLUDE[000%ஸ000%z;
|
||||
^
|
||||
./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/759573.xml:1: parser error : Content error in the internal subset
|
||||
T t (A)><!ENTITY % xx '%<![INCLUDE[000%ஸ000%z;'><!ENTITYz>%xx;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -13,8 +13,7 @@ T t (A)><!ENTITY % xx '%<![INCLUDE[000%ஸ000%z;'><!ENTITYz>%xx;
|
||||
Entity: line 1:
|
||||
%<![INCLUDE[000%ஸ000%z;
|
||||
^
|
||||
./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/759573.xml:1: parser error : Content error in the internal subset
|
||||
T t (A)><!ENTITY % xx '%<![INCLUDE[000%ஸ000%z;'><!ENTITYz>%xx;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -13,8 +13,7 @@ T t (A)><!ENTITY % xx '%<![INCLUDE[000%ஸ000%z;'><!ENTITYz>%xx;
|
||||
Entity: line 1:
|
||||
%<![INCLUDE[000%ஸ000%z;
|
||||
^
|
||||
./test/errors/759573.xml:1: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/759573.xml:1: parser error : Content error in the internal subset
|
||||
T t (A)><!ENTITY % xx '%<![INCLUDE[000%ஸ000%z;'><!ENTITYz>%xx;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -4,7 +4,6 @@
|
||||
./test/errors/content1.xml:7: parser error : expected '>'
|
||||
<!ELEMENT aElement (a |b * >
|
||||
^
|
||||
./test/errors/content1.xml:7: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/content1.xml:7: parser error : Content error in the internal subset
|
||||
<!ELEMENT aElement (a |b * >
|
||||
^
|
||||
|
@ -4,7 +4,6 @@
|
||||
./test/errors/content1.xml:7: parser error : expected '>'
|
||||
<!ELEMENT aElement (a |b * >
|
||||
^
|
||||
./test/errors/content1.xml:7: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/content1.xml:7: parser error : Content error in the internal subset
|
||||
<!ELEMENT aElement (a |b * >
|
||||
^
|
||||
|
@ -4,8 +4,7 @@
|
||||
./test/errors/content1.xml:7: parser error : expected '>'
|
||||
<!ELEMENT aElement (a |b * >
|
||||
^
|
||||
./test/errors/content1.xml:7: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors/content1.xml:7: parser error : Content error in the internal subset
|
||||
<!ELEMENT aElement (a |b * >
|
||||
^
|
||||
./test/errors/content1.xml : failed to parse
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/errors10/781205.xml:3: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors10/781205.xml:3: parser error : Content error in the internal subset
|
||||
%a;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,7 +1,6 @@
|
||||
./test/errors10/781361.xml:4: parser error : xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected
|
||||
|
||||
^
|
||||
./test/errors10/781361.xml:4: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/errors10/781361.xml:4: parser error : Content error in the internal subset
|
||||
|
||||
^
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/valid/t8.xml:6: parser error : Content error in the internal subset
|
||||
%defroot; %defmiddle; %deftest;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/valid/t8.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/valid/t8.xml:6: parser error : Content error in the internal subset
|
||||
%defroot; %defmiddle; %deftest;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/valid/t8a.xml:6: parser error : Content error in the internal subset
|
||||
%defroot;%defmiddle;%deftest;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -1,5 +1,4 @@
|
||||
./test/valid/t8a.xml:6: parser error : internal error: xmlParseInternalSubset: error detected in Markup declaration
|
||||
|
||||
./test/valid/t8a.xml:6: parser error : Content error in the internal subset
|
||||
%defroot;%defmiddle;%deftest;
|
||||
^
|
||||
Entity: line 1:
|
||||
|
@ -2193,7 +2193,7 @@ xmlXIncludeDoProcessRoot(xmlXIncludeCtxtPtr ctxt, xmlNodePtr tree) {
|
||||
int
|
||||
xmlXIncludeGetLastError(xmlXIncludeCtxtPtr ctxt) {
|
||||
if (ctxt == NULL)
|
||||
return(XML_ERR_INTERNAL_ERROR);
|
||||
return(XML_ERR_ARGUMENT);
|
||||
return(ctxt->errNo);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user