Test undefined system parameter entity in external DTD
@@ -4344,6 +4344,47 @@ START_TEST(test_recursive_external_parameter_entity)
}
END_TEST
+/* Test undefined parameter entity in external entity handler */
+static int XMLCALL
+external_entity_devaluer(XML_Parser parser,
+ const XML_Char *context,
+ const XML_Char *UNUSED_P(base),
+ const XML_Char *systemId,
+ const XML_Char *UNUSED_P(publicId))
+{
+ const char *text =
+ "<!ELEMENT doc EMPTY>\n"
+ "<!ENTITY % e1 SYSTEM 'bar'>\n"
+ "%e1;\n";
+ XML_Parser ext_parser;
+
+ if (systemId == NULL || !strcmp(systemId, "bar"))
+ return XML_STATUS_OK;
+ if (strcmp(systemId, "foo"))
+ fail("Unexpected system ID");
+ ext_parser = XML_ExternalEntityParserCreate(parser, context, NULL);
+ if (ext_parser == NULL)
+ fail("Could note create external entity parser");
+ if (_XML_Parse_SINGLE_BYTES(ext_parser, text, strlen(text),
+ XML_TRUE) == XML_STATUS_ERROR)
+ xml_failure(ext_parser);
+ return XML_STATUS_OK;
+}
+
+START_TEST(test_undefined_ext_entity_in_external_dtd)
+{
+ const char *text =
+ "<!DOCTYPE doc SYSTEM 'foo'>\n"
+ "<doc></doc>\n";
+
+ XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+ XML_SetExternalEntityRefHandler(parser, external_entity_devaluer);
+ if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
+ XML_TRUE) == XML_STATUS_ERROR)
+ xml_failure(parser);
+}
+END_TEST
+
/*
* Namespaces tests.
@@ -7496,6 +7537,7 @@ make_suite(void)
tcase_add_test(tc_basic, test_standalone_parameter_entity);
tcase_add_test(tc_basic, test_skipped_parameter_entity);
tcase_add_test(tc_basic, test_recursive_external_parameter_entity);
+ tcase_add_test(tc_basic, test_undefined_ext_entity_in_external_dtd);
suite_add_tcase(s, tc_namespace);
tcase_add_checked_fixture(tc_namespace,
