1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-24 06:50:08 +03:00

parser: Remove redundant IS_CHAR check in xmlCurrentChar

This commit is contained in:
Nick Wellnhofer 2023-10-22 15:56:46 +02:00
parent c082ef4644
commit 028566745c
3 changed files with 9 additions and 12 deletions

View File

@ -4717,7 +4717,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int partial) {
cur = CUR_CHAR(l);
while ((cur != '<') && /* checked */
(cur != '&') &&
(IS_CHAR(cur))) /* test also done in xmlCurrentChar() */ {
(IS_CHAR(cur))) {
if ((cur == ']') && (NXT(1) == ']') && (NXT(2) == '>')) {
xmlFatalErr(ctxt, XML_ERR_MISPLACED_CDATA_END, NULL);
}

View File

@ -856,6 +856,10 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
*len = 0;
} else {
*len = 1;
/*
* TODO: Null bytes should be handled by callers,
* but this can be tricky.
*/
xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
"Char 0x0 out of allowed range\n", c);
}
@ -913,11 +917,6 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
}
}
if (!IS_CHAR(val)) {
xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
"Char 0x%X out of allowed range\n", val);
}
return(val);
}

View File

@ -447,10 +447,9 @@ static int testCharRangeByte3(xmlParserCtxtPtr ctxt) {
}
/*
* There are values in that range that are not allowed in XML-1.0
* There are values that are not allowed in UTF-8
*/
else if (((value > 0xD7FF) && (value <0xE000)) ||
((value > 0xFFFD) && (value <0x10000))) {
else if ((value > 0xD7FF) && (value <0xE000)) {
if (lastError != XML_ERR_INVALID_CHAR) {
fprintf(stderr,
"Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X\n",
@ -551,10 +550,9 @@ static int testCharRangeByte4(xmlParserCtxtPtr ctxt) {
}
/*
* There are values in that range that are not allowed in XML-1.0
* There are values in that are not allowed in UTF-8
*/
else if (((value > 0xD7FF) && (value <0xE000)) ||
((value > 0xFFFD) && (value <0x10000)) ||
else if (((value > 0xD7FF) && (value < 0xE000)) ||
(value > 0x10FFFF)) {
if (lastError != XML_ERR_INVALID_CHAR) {
fprintf(stderr,