From b3cc5a74d970e0f7be1ac3a29de79fb7573d3177 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Fri, 3 Feb 2017 16:42:14 +0000 Subject: [PATCH] Test XML_ParserReset in internal entity expansion --- expat/tests/runtests.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 2fad520b..6c480a00 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -1469,7 +1469,6 @@ START_TEST(test_set_base) } END_TEST - /* Test attribute counts, indexing, etc */ typedef struct attrInfo { const char *name; @@ -1566,6 +1565,34 @@ START_TEST(test_attributes) } END_TEST +/* Test reset works correctly in the middle of processing an internal + * entity. Exercises some obscure code in XML_ParserReset(). + */ +START_TEST(test_reset_in_entity) +{ + const char *text = + "\n" + "\n" + "]>\n" + "&entity;"; + XML_ParsingStatus status; + + resumable = XML_TRUE; + XML_SetCharacterDataHandler(parser, clearing_aborting_character_handler); + if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR) + xml_failure(parser); + XML_GetParsingStatus(parser, &status); + if (status.parsing != XML_SUSPENDED) + fail("Parsing status not SUSPENDED"); + XML_ParserReset(parser, NULL); + XML_GetParsingStatus(parser, &status); + if (status.parsing != XML_INITIALIZED) + fail("Parsing status doesn't reset to INITIALIZED"); +} +END_TEST + + /* * Namespaces tests. */ @@ -2487,6 +2514,7 @@ make_suite(void) tcase_add_test(tc_basic, test_set_foreign_dtd); tcase_add_test(tc_basic, test_set_base); tcase_add_test(tc_basic, test_attributes); + tcase_add_test(tc_basic, test_reset_in_entity); suite_add_tcase(s, tc_namespace); tcase_add_checked_fixture(tc_namespace,