]> granicus.if.org Git - libexpat/commitdiff
Test single stray ] doesn't close a CDATA section
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 14 Jun 2017 18:20:29 +0000 (19:20 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 20:49:19 +0000 (22:49 +0200)
Also uses multi-byte characters around the ] to exercise more code.

expat/tests/runtests.c

index 5a5a171d324d57a2472a5dbe5a7e75ad3de89471..66f43e40d1c1f9f8f681ed6bf50b61c0d852430d 100644 (file)
@@ -5996,6 +5996,16 @@ START_TEST(test_utf8_in_cdata_section)
 }
 END_TEST
 
+/* Test that little-endian UTF-16 in a CDATA section is handled */
+START_TEST(test_utf8_in_cdata_section_2)
+{
+    const char *text = "<doc><![CDATA[\xc3\xa9]\xc3\xa9two]]></doc>";
+    const XML_Char *expected = "\xc3\xa9]\xc3\xa9two";
+
+    run_character_check(text, expected);
+}
+END_TEST
+
 /*
  * Namespaces tests.
  */
@@ -11317,6 +11327,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_ext_entity_utf16_unknown);
     tcase_add_test(tc_basic, test_ext_entity_utf8_non_bom);
     tcase_add_test(tc_basic, test_utf8_in_cdata_section);
+    tcase_add_test(tc_basic, test_utf8_in_cdata_section_2);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,