[Expat-checkins] CVS: expat/tests runtests.c,1.8,1.9
Fred L. Drake
fdrake@users.sourceforge.net
Fri Apr 19 12:27:10 2002
Update of /cvsroot/expat/expat/tests
In directory usw-pr-cvs1:/tmp/cvs-serv1426/tests
Modified Files:
runtests.c
Log Message:
Add a test that checks that illegal UTF-8 sequences are not allowed to pass
when we are using UTF-8 encoding.
This closes SF bug #477667.
Index: runtests.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/runtests.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** runtests.c 19 Apr 2002 18:50:26 -0000 1.8
--- runtests.c 19 Apr 2002 19:18:35 -0000 1.9
***************
*** 213,216 ****
--- 213,240 ----
/* End regression test for SF bug #514281. */
+ /* Regression test for SF bug #477667.
+ * This test assures that any 8-bit character followed by a 7-bit
+ * character will not be mistakenly interpreted as a valid UTF-8
+ * sequence.
+ */
+ START_TEST(test_illegal_utf8)
+ {
+ char text[100];
+ int i;
+
+ for (i = 128; i <= 255; ++i) {
+ sprintf(text, "<e>%ccd</e>", i);
+ if (XML_Parse(parser, text, strlen(text), 1)) {
+ sprintf(text,
+ "expected token error for '%c'(ordinal %d) in UTF-8 text",
+ i, i);
+ fail(text);
+ }
+ else if (XML_GetErrorCode(parser) != XML_ERROR_INVALID_TOKEN)
+ xml_failure();
+ }
+ }
+ END_TEST
+
/* Helpers used by the following test; this checks any "attr" and "refs"
***************
*** 338,341 ****
--- 362,366 ----
tcase_add_test(tc_chars, test_bom_utf16_be);
tcase_add_test(tc_chars, test_bom_utf16_le);
+ tcase_add_test(tc_chars, test_illegal_utf8);
/* Regression test for SF bug #491986. */
tcase_add_test(tc_chars, test_danish_latin1);