mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-07 22:19:12 +00:00
Move external_entity_ref_param_checker out of runtests.c
This commit is contained in:
parent
f0adbc47ef
commit
4c28bb1681
3 changed files with 32 additions and 26 deletions
|
@ -585,6 +585,32 @@ external_entity_param_checker(XML_Parser parser, const XML_Char *context,
|
|||
return XML_STATUS_OK;
|
||||
}
|
||||
|
||||
int XMLCALL
|
||||
external_entity_ref_param_checker(XML_Parser parameter, const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId) {
|
||||
const char *text = "<!ELEMENT doc (#PCDATA)*>";
|
||||
XML_Parser ext_parser;
|
||||
|
||||
UNUSED_P(base);
|
||||
UNUSED_P(systemId);
|
||||
UNUSED_P(publicId);
|
||||
if ((void *)parameter != g_handler_data)
|
||||
fail("External entity ref handler parameter not correct");
|
||||
|
||||
/* Here we use the global 'parser' variable */
|
||||
ext_parser = XML_ExternalEntityParserCreate(g_parser, context, NULL);
|
||||
if (ext_parser == NULL)
|
||||
fail("Could not create external entity parser");
|
||||
if (_XML_Parse_SINGLE_BYTES(ext_parser, text, (int)strlen(text), XML_TRUE)
|
||||
== XML_STATUS_ERROR)
|
||||
xml_failure(ext_parser);
|
||||
|
||||
XML_ParserFree(ext_parser);
|
||||
return XML_STATUS_OK;
|
||||
}
|
||||
|
||||
/* NotStandalone handlers */
|
||||
|
||||
int XMLCALL
|
||||
|
|
|
@ -208,6 +208,12 @@ extern int XMLCALL external_entity_param_checker(XML_Parser parser,
|
|||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
extern int XMLCALL external_entity_ref_param_checker(XML_Parser parameter,
|
||||
const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId);
|
||||
|
||||
/* NotStandalone handlers */
|
||||
|
||||
extern int XMLCALL reject_not_standalone_handler(void *userData);
|
||||
|
|
|
@ -83,32 +83,6 @@ XML_Parser g_parser = NULL;
|
|||
* global 'parser' variable to create our external entity parser from,
|
||||
* since there are code paths we need to ensure get executed.
|
||||
*/
|
||||
static int XMLCALL
|
||||
external_entity_ref_param_checker(XML_Parser parameter, const XML_Char *context,
|
||||
const XML_Char *base,
|
||||
const XML_Char *systemId,
|
||||
const XML_Char *publicId) {
|
||||
const char *text = "<!ELEMENT doc (#PCDATA)*>";
|
||||
XML_Parser ext_parser;
|
||||
|
||||
UNUSED_P(base);
|
||||
UNUSED_P(systemId);
|
||||
UNUSED_P(publicId);
|
||||
if ((void *)parameter != g_handler_data)
|
||||
fail("External entity ref handler parameter not correct");
|
||||
|
||||
/* Here we use the global 'parser' variable */
|
||||
ext_parser = XML_ExternalEntityParserCreate(g_parser, context, NULL);
|
||||
if (ext_parser == NULL)
|
||||
fail("Could not create external entity parser");
|
||||
if (_XML_Parse_SINGLE_BYTES(ext_parser, text, (int)strlen(text), XML_TRUE)
|
||||
== XML_STATUS_ERROR)
|
||||
xml_failure(ext_parser);
|
||||
|
||||
XML_ParserFree(ext_parser);
|
||||
return XML_STATUS_OK;
|
||||
}
|
||||
|
||||
START_TEST(test_ext_entity_ref_parameter) {
|
||||
const char *text = "<?xml version='1.0' encoding='us-ascii'?>\n"
|
||||
"<!DOCTYPE doc SYSTEM 'foo'>\n"
|
||||
|
|
Loading…
Add table
Reference in a new issue