]> granicus.if.org Git - libexpat/commitdiff
Test invalid characters in a DOCTYPE
authorRhodri James <rhodri@kynesim.co.uk>
Fri, 16 Jun 2017 14:23:48 +0000 (15:23 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 20:49:20 +0000 (22:49 +0200)
expat/tests/runtests.c

index 6dc6ff839c4c69399b680006c75d3e6c5737e247..bc4e8e91df4672cd3587b2e6597c6d9c0dc9d01c 100644 (file)
@@ -6242,6 +6242,21 @@ START_TEST(test_bad_attr_desc_keyword_utf16)
 }
 END_TEST
 
+/* Test that invalid syntax in a <!DOCTYPE> is rejected.  Do this
+ * using prefix-encoding (see above) to trigger specific code paths
+ */
+START_TEST(test_bad_doctype)
+{
+    const char *text =
+        "<?xml version='1.0' encoding='prefix-conv'?>\n"
+        "<!DOCTYPE doc [ \x80\x44 ]><doc/>";
+
+    XML_SetUnknownEncodingHandler(parser, MiscEncodingHandler, NULL);
+    expect_failure(text, XML_ERROR_SYNTAX,
+                   "Invalid bytes in DOCTYPE not faulted");
+}
+END_TEST
+
 /*
  * Namespaces tests.
  */
@@ -11657,6 +11672,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_utf16_pe);
     tcase_add_test(tc_basic, test_bad_attr_desc_keyword);
     tcase_add_test(tc_basic, test_bad_attr_desc_keyword_utf16);
+    tcase_add_test(tc_basic, test_bad_doctype);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,