From cc6edd8913707442efc470af5e6ec5aacfefc2ba Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Fri, 10 Mar 2017 15:07:48 +0000 Subject: [PATCH] Test DTD processing stops for undefined parameter entities --- expat/tests/runtests.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 47b849d6..3c0791e2 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -4159,6 +4159,28 @@ START_TEST(test_predefined_entity_redefinition) } END_TEST +/* Test that the parser stops processing the DTD after an unresolved + * parameter entity is encountered. + */ +START_TEST(test_dtd_stop_processing) +{ + const char *text = + "\n" + "]>"; + + XML_SetEntityDeclHandler(parser, dummy_entity_decl_handler); + dummy_handler_flags = 0; + if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), + XML_TRUE) == XML_STATUS_ERROR) + xml_failure(parser); + if (dummy_handler_flags != 0) + fail("DTD processing still going after undefined PE"); +} +END_TEST + + /* * Namespaces tests. */ @@ -7007,6 +7029,7 @@ make_suite(void) tcase_add_test(tc_basic, test_bad_public_doctype); tcase_add_test(tc_basic, test_attribute_enum_value); tcase_add_test(tc_basic, test_predefined_entity_redefinition); + tcase_add_test(tc_basic, test_dtd_stop_processing); suite_add_tcase(s, tc_namespace); tcase_add_checked_fixture(tc_namespace,