]> granicus.if.org Git - libexpat/commitdiff
Test ASCII-like unknown encoding correctly rejects invalid characters
authorRhodri James <rhodri@kynesim.co.uk>
Fri, 9 Jun 2017 14:23:38 +0000 (15:23 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 22 Jul 2017 20:49:17 +0000 (22:49 +0200)
expat/tests/runtests.c

index 33c6df3ab0cff0bf441c146b7e681ed70c20e250..53b4b19c5905e6f83596cec00832321c4a9debda 100644 (file)
@@ -5511,6 +5511,18 @@ START_TEST(test_unknown_ascii_encoding_ok)
 }
 END_TEST
 
+START_TEST(test_unknown_ascii_encoding_fail)
+{
+    const char *text =
+        "<?xml version='1.0' encoding='experimental'?>\n"
+        "<doc>Hello, \x80 world</doc>";
+
+    XML_SetUnknownEncodingHandler(parser, AsciiAsUnknownEncodingHandler, NULL);
+    expect_failure(text, XML_ERROR_INVALID_TOKEN,
+                   "Invalid character not faulted");
+}
+END_TEST
+
 
 /*
  * Namespaces tests.
@@ -10777,6 +10789,7 @@ make_suite(void)
     tcase_add_test(tc_basic, test_unknown_encoding_long_name_2);
     tcase_add_test(tc_basic, test_invalid_unknown_encoding);
     tcase_add_test(tc_basic, test_unknown_ascii_encoding_ok);
+    tcase_add_test(tc_basic, test_unknown_ascii_encoding_fail);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,