}
END_TEST
+/* Test unrecognised encoding handler */
+static void dummy_release(void *UNUSED_P(data))
+{
+}
+
+static int XMLCALL
+UnrecognisedEncodingHandler(void *UNUSED_P(data),
+ const XML_Char *UNUSED_P(encoding),
+ XML_Encoding *info)
+{
+ info->data = NULL;
+ info->convert = NULL;
+ info->release = dummy_release;
+ return XML_STATUS_ERROR;
+}
+
+START_TEST(test_unrecognised_encoding_internal_entity)
+{
+ const char *text =
+ "<?xml version='1.0' encoding='unsupported-encoding'?>\n"
+ "<!DOCTYPE test [<!ENTITY foo 'bar'>]>\n"
+ "<test a='&foo;'/>";
+
+ XML_SetUnknownEncodingHandler(parser,
+ UnrecognisedEncodingHandler,
+ NULL);
+ if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), XML_TRUE) != XML_STATUS_ERROR)
+ fail("Unrecognised encoding not rejected");
+}
+END_TEST
+
/* Regression test for SF bug #620106. */
static int XMLCALL
external_entity_loader_set_encoding(XML_Parser parser,
}
END_TEST
-static void dummy_release(void *UNUSED_P(data))
-{
-}
-
static int XMLCALL
unknown_released_encoding_handler(void *UNUSED_P(data),
const XML_Char *encoding,
tcase_add_test(tc_basic, test_attr_whitespace_normalization);
tcase_add_test(tc_basic, test_xmldecl_misplaced);
tcase_add_test(tc_basic, test_unknown_encoding_internal_entity);
+ tcase_add_test(tc_basic, test_unrecognised_encoding_internal_entity);
tcase_add_test(tc_basic,
test_wfc_undeclared_entity_unread_external_subset);
tcase_add_test(tc_basic, test_wfc_undeclared_entity_no_external_subset);