From 632b20c24fc40bab5dec025de20441afca1d3815 Mon Sep 17 00:00:00 2001 From: "Fred L. Drake, Jr." Date: Mon, 22 Jul 2002 17:15:48 +0000 Subject: [PATCH] Added regression test for SF bug #584832, adapted from contributed test. --- expat/tests/runtests.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 54ce61fc..7c11f791 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -481,6 +481,35 @@ START_TEST(test_xmldecl_misplaced) } END_TEST +/* Regression test for SF bug #584832. */ +static int +UnknownEncodingHandler(void *data,const XML_Char *encoding,XML_Encoding *info) +{ + if (strcmp(encoding,"unsupported-encoding") == 0) { + int i; + for (i = 0; i < 256; ++i) + info->map[i] = i; + info->data=NULL; + info->convert=NULL; + info->release=NULL; + return 1; + } + return 0; +} + +START_TEST(test_xmldecl_unknown_encoding_internal_entity) +{ + char *text = + "\n" + "]>\n" + ""; + + XML_SetUnknownEncodingHandler(parser, UnknownEncodingHandler, NULL); + if (!XML_Parse(parser, text, strlen(text), 1)) + xml_failure(parser); +} +END_TEST + /* * Namespaces tests. @@ -674,6 +703,7 @@ make_basic_suite(void) suite_add_tcase(s, tc_xmldecl); tcase_add_checked_fixture(tc_xmldecl, basic_setup, basic_teardown); tcase_add_test(tc_xmldecl, test_xmldecl_misplaced); + tcase_add_test(tc_xmldecl, test_xmldecl_unknown_encoding_internal_entity); suite_add_tcase(s, tc_namespace); tcase_add_checked_fixture(tc_namespace, -- 2.40.0