Commit 37fd3074 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fixed a bug where invalid charrefs may not be detected sometimes as

* parser.c: fixed a bug where invalid charrefs may not be detected
  sometimes as pointed by Morus Walter.
* test/errors/charref1.xm result/errors/charref1.xml*: added the
  test in the regression suite.
Daniel
parent 767265dd
Thu Jun 3 13:20:36 CEST 2004 Daniel Veillard <daniel@veillard.com>
* parser.c: fixed a bug where invalid charrefs may not be detected
sometimes as pointed by Morus Walter.
* test/errors/charref1.xm result/errors/charref1.xml*: added the
test in the regression suite.
Thu Jun 3 18:38:27 HKT 2004 William Brack <wbrack@mmm.com.hk>
 
* xmlschemas.c: small change to xmlSchemaValidateAttributes,
......
......@@ -1456,6 +1456,7 @@ int
xmlParseCharRef(xmlParserCtxtPtr ctxt) {
unsigned int val = 0;
int count = 0;
unsigned int outofrange = 0;
/*
* Using RAW/CUR/NEXT is okay since we are working on ASCII range here
......@@ -1480,6 +1481,9 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
NEXT;
count++;
}
......@@ -1504,6 +1508,9 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
NEXT;
count++;
}
......@@ -1522,7 +1529,7 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
* Characters referred to using character references must match the
* production for Char.
*/
if (IS_CHAR(val)) {
if ((IS_CHAR(val) && (outofrange == 0))) {
return(val);
} else {
xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
......@@ -1554,7 +1561,8 @@ static int
xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
const xmlChar *ptr;
xmlChar cur;
int val = 0;
unsigned int val = 0;
unsigned int outofrange = 0;
if ((str == NULL) || (*str == NULL)) return(0);
ptr = *str;
......@@ -1574,6 +1582,9 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
ptr++;
cur = *ptr;
}
......@@ -1590,6 +1601,9 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
val = 0;
break;
}
if (val > 0x10FFFF)
outofrange = val;
ptr++;
cur = *ptr;
}
......@@ -1606,7 +1620,7 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
* Characters referred to using character references must match the
* production for Char.
*/
if (IS_CHAR(val)) {
if ((IS_CHAR(val) && (outofrange == 0))) {
return(val);
} else {
xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
......
./test/errors/charref1.xml:1: parser error : xmlParseCharRef: invalid xmlChar value 60
<bla>&#010100000000000000000000000000000000000000000000000060;</bla>
^
./test/errors/charref1.xml:1: parser error : xmlParseCharRef: invalid xmlChar value 60
<bla>&#010100000000000000000000000000000000000000000000000060;</bla>
^
<bla>&#010100000000000000000000000000000000000000000000000060;</bla>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment