From: Rhodri James Date: Fri, 16 Jun 2017 15:57:23 +0000 (+0100) Subject: Test UTF-16 non-zero high byte characters in document local name X-Git-Tag: R_2_2_3~22^2~38 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1346f5cd746b3f806c2a53f234bd5c95d40d6af7;p=libexpat Test UTF-16 non-zero high byte characters in document local name Tests DOCTYPE handling of non-ASCII characters leading the local element (i.e. the part after the colon) of a document name --- diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index c566e5c1..635ca695 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -7000,6 +7000,34 @@ START_TEST(test_ns_utf16_element_leafname) } END_TEST +START_TEST(test_ns_utf16_doctype) +{ + const char text[] = + /* ]>\n + * where {KHO KHWAI} = U+0E04 = 0xe0 0xb8 0x84 in UTF-8 + */ + "\0<\0!\0D\0O\0C\0T\0Y\0P\0E\0 \0f\0o\0o\0:\x0e\x04\0 " + "\0[\0 \0<\0!\0E\0N\0T\0I\0T\0Y\0 \0b\0a\0r\0 \0'\0b\0a\0z\0'\0>\0 " + "\0]\0>\0\n" + /* &bar; */ + "\0<\0f\0o\0o\0:\x0e\x04\0 " + "\0x\0m\0l\0n\0s\0:\0f\0o\0o\0=\0'\0U\0R\0I\0'\0>" + "\0&\0b\0a\0r\0;" + "\0<\0/\0f\0o\0o\0:\x0e\x04\0>"; + const XML_Char *expected = "URI \xe0\xb8\x84"; + CharData storage; + + CharData_Init(&storage); + XML_SetUserData(parser, &storage); + XML_SetStartElementHandler(parser, start_element_event_handler); + XML_SetUnknownEncodingHandler(parser, MiscEncodingHandler, NULL); + if (_XML_Parse_SINGLE_BYTES(parser, text, sizeof(text)-1, + XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); + CharData_CheckXMLChars(&storage, expected); +} +END_TEST + /* Control variable; the number of times duff_allocator() will successfully allocate */ #define ALLOC_ALWAYS_SUCCEED (-1) #define REALLOC_ALWAYS_SUCCEED (-1) @@ -11727,6 +11755,7 @@ make_suite(void) tcase_add_test(tc_namespace, test_ns_bad_element_leafname); tcase_add_test(tc_namespace, test_ns_utf16_leafname); tcase_add_test(tc_namespace, test_ns_utf16_element_leafname); + tcase_add_test(tc_namespace, test_ns_utf16_doctype); suite_add_tcase(s, tc_misc); tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);