From: Rhodri James Date: Tue, 28 Feb 2017 12:23:19 +0000 (+0000) Subject: Test external entity parsing suppressed with UNLESS_STANDALONE parameter X-Git-Tag: R_2_2_3~22^2~260 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5279d9c5881ca8fce874b8d19f56c7132a816ef5;p=libexpat Test external entity parsing suppressed with UNLESS_STANDALONE parameter --- diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 9117e666..373a6cfe 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -1330,6 +1330,26 @@ START_TEST(test_wfc_undeclared_entity_with_external_subset_standalone) { } END_TEST +/* Test that external entity handling is not done if the parsing flag + * is set to UNLESS_STANDALONE + */ +START_TEST(test_entity_with_external_subset_unless_standalone) { + const char *text = + "\n" + "\n" + "&entity;"; + ExtTest test_data = { "", NULL, NULL }; + + XML_SetParamEntityParsing(parser, + XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE); + XML_SetUserData(parser, &test_data); + XML_SetExternalEntityRefHandler(parser, external_entity_loader); + expect_failure(text, + XML_ERROR_UNDEFINED_ENTITY, + "Parser did not report undefined entity"); +} +END_TEST + /* Test that no error is reported for unknown entities if we have read an external subset, and standalone is false. */ @@ -5745,6 +5765,8 @@ make_suite(void) tcase_add_test(tc_basic, test_not_standalone_handler_accept); tcase_add_test(tc_basic, test_wfc_undeclared_entity_with_external_subset_standalone); + tcase_add_test(tc_basic, + test_entity_with_external_subset_unless_standalone); tcase_add_test(tc_basic, test_wfc_no_recursive_entity_refs); tcase_add_test(tc_basic, test_ext_entity_set_encoding); tcase_add_test(tc_basic, test_ext_entity_no_handler);