1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

parser: Downgrade XML_ERR_UNSUPPORTED_ENCODING to warning

If the actual encoding is UTF-8 or ASCII, we don't want to fail.
This commit is contained in:
Nick Wellnhofer 2023-12-27 21:30:13 +01:00
parent 24b7144f2c
commit 451572615c
2 changed files with 5 additions and 42 deletions

View File

@ -6864,12 +6864,6 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
* We must have the encoding declaration * We must have the encoding declaration
*/ */
xmlParseEncodingDecl(ctxt); xmlParseEncodingDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
return;
}
SKIP_BLANKS; SKIP_BLANKS;
if ((RAW == '?') && (NXT(1) == '>')) { if ((RAW == '?') && (NXT(1) == '>')) {
@ -6916,13 +6910,6 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) { if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
xmlParseTextDecl(ctxt); xmlParseTextDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
xmlHaltParser(ctxt);
return;
}
} }
if (ctxt->myDoc == NULL) { if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0"); ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
@ -10371,12 +10358,6 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n"); xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
} }
xmlParseEncodingDecl(ctxt); xmlParseEncodingDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
return;
}
/* /*
* We may have the standalone status. * We may have the standalone status.
@ -10527,12 +10508,6 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
* Note that we will switch encoding on the fly. * Note that we will switch encoding on the fly.
*/ */
xmlParseXMLDecl(ctxt); xmlParseXMLDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
return(-1);
}
SKIP_BLANKS; SKIP_BLANKS;
} else { } else {
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION); ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
@ -10663,12 +10638,6 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
* Note that we will switch encoding on the fly. * Note that we will switch encoding on the fly.
*/ */
xmlParseXMLDecl(ctxt); xmlParseXMLDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
return(-1);
}
SKIP_BLANKS; SKIP_BLANKS;
} else { } else {
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION); ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
@ -11102,14 +11071,6 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
(IS_BLANK_CH(ctxt->input->cur[5]))) { (IS_BLANK_CH(ctxt->input->cur[5]))) {
ret += 5; ret += 5;
xmlParseXMLDecl(ctxt); xmlParseXMLDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right
* here
*/
xmlHaltParser(ctxt);
return(0);
}
} else { } else {
ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION); ctxt->version = xmlCharStrdup(XML_DEFAULT_VERSION);
if (ctxt->version == NULL) { if (ctxt->version == NULL) {

View File

@ -175,9 +175,11 @@ xmlCtxtErrIO(xmlParserCtxtPtr ctxt, int code, const char *uri)
if (ctxt == NULL) if (ctxt == NULL)
return; return;
if ((code == XML_IO_ENOENT) || if (code == XML_ERR_UNSUPPORTED_ENCODING) {
(code == XML_IO_NETWORK_ATTEMPT) || level = XML_ERR_WARNING;
(code == XML_IO_UNKNOWN)) { } else if ((code == XML_IO_ENOENT) ||
(code == XML_IO_NETWORK_ATTEMPT) ||
(code == XML_IO_UNKNOWN)) {
if (ctxt->validate == 0) if (ctxt->validate == 0)
level = XML_ERR_WARNING; level = XML_ERR_WARNING;
else else