]> granicus.if.org Git - libexpat/commitdiff
Test PI in UTF-16 with non-ASCII target name
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 14 Jun 2017 16:13:10 +0000 (17:13 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 20:49:19 +0000 (22:49 +0200)
expat/tests/runtests.c

index 4e7c12cdbdd870b42623c89fddde56af31b57efb..e1933e53dbb4d8e36aac05d72cb64d51dba1941a 100644 (file)
@@ -5324,6 +5324,29 @@ START_TEST(test_pi_xmm)
 }
 END_TEST
 
+START_TEST(test_utf16_pi)
+{
+    const char text[] =
+        /* <?{KHO KHWAI}{CHO CHAN}?>
+         * where {KHO KHWAI} = U+0E04
+         * and   {CHO CHAN}  = U+0E08
+         */
+        "<\0?\0\x04\x0e\x08\x0e?\0>\0"
+        /* <q/> */
+        "<\0q\0/\0>\0";
+    const XML_Char *expected = "\xe0\xb8\x84\xe0\xb8\x88: \n";
+    CharData storage;
+
+    CharData_Init(&storage);
+    XML_SetProcessingInstructionHandler(parser, accumulate_pi_characters);
+    XML_SetUserData(parser, &storage);
+    if (_XML_Parse_SINGLE_BYTES(parser, text, sizeof(text)-1,
+                                XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+    CharData_CheckXMLChars(&storage, expected);
+}
+END_TEST
+
 /* Test that the unknown encoding handler with map entries that expect
  * conversion but no conversion function is faulted
  */
@@ -11260,6 +11283,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_pi_yml);
     tcase_add_test(tc_basic, test_pi_xnl);
     tcase_add_test(tc_basic, test_pi_xmm);
+    tcase_add_test(tc_basic, test_utf16_pi);
     tcase_add_test(tc_basic, test_missing_encoding_conversion_fn);
     tcase_add_test(tc_basic, test_failing_encoding_conversion_fn);
     tcase_add_test(tc_basic, test_unknown_encoding_success);