]> granicus.if.org Git - libexpat/commitdiff
Check handling of long element names with namespaces
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 8 Feb 2017 18:28:39 +0000 (18:28 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sat, 15 Jul 2017 23:52:59 +0000 (01:52 +0200)
expat/tests/runtests.c

index bb083645419acab7bdf94990813992fa423d261c..ccdbc6f5a6af867021d8f84168691bcf19735d57 100644 (file)
@@ -2811,6 +2811,32 @@ START_TEST(test_ns_parser_reset)
 }
 END_TEST
 
+/* Test that long element names with namespaces are handled correctly */
+START_TEST(test_ns_long_element)
+{
+    const char *text =
+        "<foo:thisisalongenoughelementnametotriggerareallocation\n"
+        " xmlns:foo='http://expat.sf.net/' bar:a='12'\n"
+        " xmlns:bar='http://expat.sf.net/'>"
+        "</foo:thisisalongenoughelementnametotriggerareallocation>";
+    const char *elemstr[] = {
+        "http://expat.sf.net/"
+        " thisisalongenoughelementnametotriggerareallocation foo",
+        "http://expat.sf.net/ a bar"
+    };
+
+    XML_SetReturnNSTriplet(parser, XML_TRUE);
+    XML_SetUserData(parser, elemstr);
+    XML_SetElementHandler(parser,
+                          triplet_start_checker,
+                          triplet_end_checker);
+    if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
+                                XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+
 /* Control variable; the number of times duff_allocator() will successfully allocate */
 #define ALLOC_ALWAYS_SUCCEED (-1)
 #define REALLOC_ALWAYS_SUCCEED (-1)
@@ -3604,6 +3630,7 @@ make_suite(void)
     tcase_add_test(tc_namespace, test_ns_unbound_prefix_on_attribute);
     tcase_add_test(tc_namespace, test_ns_unbound_prefix_on_element);
     tcase_add_test(tc_namespace, test_ns_parser_reset);
+    tcase_add_test(tc_namespace, test_ns_long_element);
 
     suite_add_tcase(s, tc_misc);
     tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);