]> granicus.if.org Git - libexpat/commitdiff
Test bad non-start of name in unknown encoding
authorRhodri James <rhodri@kynesim.co.uk>
Thu, 8 Jun 2017 18:56:47 +0000 (19:56 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 20:49:17 +0000 (22:49 +0200)
expat/tests/runtests.c

index 6498444e96bf7120c904c63d48c3a7e13ebee400..2a3b9669bfc6387823ee4344d3e6e0f820bb3a98 100644 (file)
@@ -5384,6 +5384,20 @@ START_TEST(test_unknown_encoding_bad_name)
 }
 END_TEST
 
+/* Test bad mid-name character in unknown encoding */
+START_TEST(test_unknown_encoding_bad_name_2)
+{
+    const char *text =
+        "<?xml version='1.0' encoding='experimental'?>\n"
+        "<d\xffoc>Hello, world</d\xffoc>";
+
+    XML_SetUnknownEncodingHandler(parser, BadEncodingHandler,
+                                  (void *)PREFIX_CONVERTER);
+    expect_failure(text, XML_ERROR_INVALID_TOKEN,
+                   "Bad name in unknown encoding not faulted");
+}
+END_TEST
+
 /* Be tidy */
 #undef NO_CONVERTER
 #undef FAILING_CONVERTER
@@ -10649,6 +10663,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_failing_encoding_conversion_fn);
     tcase_add_test(tc_basic, test_unknown_encoding_success);
     tcase_add_test(tc_basic, test_unknown_encoding_bad_name);
+    tcase_add_test(tc_basic, test_unknown_encoding_bad_name_2);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,