_expect_failure(char *text, enum XML_Error errorCode, char *errorMessage,
char *file, int lineno)
{
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_OK)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_OK)
/* Hackish use of _fail_unless() macro, but let's us report
the right filename and line number. */
_fail_unless(0, file, lineno, errorMessage);
char text[] = "<doc>\0</doc>";
/* test that a NUL byte (in US-ASCII data) is an error */
- if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_OK)
+ if (XML_Parse(parser, text, sizeof(text) - 1, XML_TRUE) == XML_STATUS_OK)
fail("Parser did not report error on NUL-byte.");
if (XML_GetErrorCode(parser) != XML_ERROR_INVALID_TOKEN)
xml_failure(parser);
/* This test is really just making sure we don't core on a UTF-8 BOM. */
char *text = "\357\273\277<e/>";
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
{
char text[] = "\376\377\0<\0e\0/\0>";
- if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, sizeof(text)-1, XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
{
char text[] = "\377\376<\0e\0/\0>\0";
- if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, sizeof(text)-1, XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
CharData_Init(&storage);
XML_SetUserData(parser, &storage);
XML_SetCharacterDataHandler(parser, accumulate_characters);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
_xml_failure(parser, file, line);
CharData_CheckXMLChars(&storage, expected);
}
CharData_Init(&storage);
XML_SetUserData(parser, &storage);
XML_SetStartElementHandler(parser, accumulate_attribute);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
_xml_failure(parser, file, line);
CharData_CheckXMLChars(&storage, expected);
}
for (i = 128; i <= 255; ++i) {
sprintf(text, "<e>%ccd</e>", i);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_OK) {
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_OK) {
sprintf(text,
"expected token error for '%c' (ordinal %d) in UTF-8 text",
i, i);
"\000<\000d\000o\000c\000 \000a\000=\000'\0001\0002\0003\000'"
"\000>\000s\000o\000m\000e\000 \000t\000e\000x\000t\000<\000/"
"\000d\000o\000c\000>";
- if (XML_Parse(parser, text, sizeof(text) - 1, 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, sizeof(text)-1, XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
if (first_chunk_bytes >= sizeof(text) - 1)
fail("bad value of first_chunk_bytes");
- if (XML_Parse(parser, text, first_chunk_bytes, 0) == XML_STATUS_ERROR)
+ if ( XML_Parse(parser, text, first_chunk_bytes, XML_FALSE)
+ == XML_STATUS_ERROR)
xml_failure(parser);
else {
enum XML_Status rc;
rc = XML_Parse(parser, text + first_chunk_bytes,
- sizeof(text) - first_chunk_bytes - 1, 1);
+ sizeof(text) - first_chunk_bytes - 1, XML_TRUE);
if (rc == XML_STATUS_ERROR)
xml_failure(parser);
}
"\n</tag>";
int lineno;
- if (XML_Parse(parser, text, strlen(text), 0) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR)
xml_failure(parser);
lineno = XML_GetCurrentLineNumber(parser);
if (lineno != 4) {
char *text = "<tag></tag>";
int colno;
- if (XML_Parse(parser, text, strlen(text), 0) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR)
xml_failure(parser);
colno = XML_GetCurrentColumnNumber(parser);
if (colno != 11) {
XML_SetUserData(parser, &storage);
XML_SetStartElementHandler(parser, start_element_event_handler2);
XML_SetEndElementHandler(parser, end_element_event_handler2);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
CharData_CheckString(&storage, expected);
" <b>\n"
" </a>"; /* missing </b> */
int lineno;
- if (XML_Parse(parser, text, strlen(text), 0) != XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_FALSE) != XML_STATUS_ERROR)
fail("Expected a parse error");
lineno = XML_GetCurrentLineNumber(parser);
" <b>\n"
" </a>"; /* missing </b> */
int colno;
- if (XML_Parse(parser, text, strlen(text), 0) != XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_FALSE) != XML_STATUS_ERROR)
fail("Expected a parse error");
colno = XML_GetCurrentColumnNumber(parser);
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
"</e>";
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
CharData_Init(&storage);
XML_SetUserData(parser, &storage);
XML_SetEndElementHandler(parser, end_element_event_handler);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
CharData_CheckString(&storage, expected);
}
XML_SetStartElementHandler(parser,
check_attr_contains_normalized_whitespace);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
"<test a='&foo;'/>";
XML_SetUnknownEncodingHandler(parser, UnknownEncodingHandler, NULL);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
fail("Could not create external entity parser.");
if (!XML_SetEncoding(extparser, "utf-8"))
fail("XML_SetEncoding() ignored for external entity");
- if (XML_Parse(extparser, text, strlen(text), 1) == XML_STATUS_ERROR) {
+ if ( XML_Parse(extparser, text, strlen(text), XML_TRUE)
+ == XML_STATUS_ERROR) {
xml_failure(parser);
return 0;
}
"<!DOCTYPE doc SYSTEM 'foo'>\n"
"<doc>&entity;</doc>";
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
extparser = XML_ExternalEntityParserCreate(parser, context, NULL);
if (extparser == NULL)
fail("Could not create external entity parser.");
- if (XML_Parse(extparser, text, strlen(text), 1) == XML_STATUS_ERROR) {
+ if ( XML_Parse(extparser, text, strlen(text), XML_TRUE)
+ == XML_STATUS_ERROR) {
xml_failure(parser);
return XML_STATUS_ERROR;
}
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetUserData(parser, foo_text);
XML_SetExternalEntityRefHandler(parser, external_entity_loader);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
" <e xmlns:prefix=''/>\n"
"</doc>";
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
"http://expat.sf.net/ e foo",
"http://expat.sf.net/ a bar"
};
- XML_SetReturnNSTriplet(parser, 1);
+ XML_SetReturnNSTriplet(parser, XML_TRUE);
XML_SetUserData(parser, elemstr);
XML_SetElementHandler(parser, triplet_start_checker, triplet_end_checker);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
XML_SetUserData(parser, &storage);
XML_SetElementHandler(parser,
overwrite_start_checker, overwrite_end_checker);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
CharData_CheckString(&storage, result);
}
"attribute http://xml.libexpat.org/ attr2 n\n"
"end http://xml.libexpat.org/ g n\n"
"end http://xml.libexpat.org/ e n\n";
- XML_SetReturnNSTriplet(parser, 1);
+ XML_SetReturnNSTriplet(parser, XML_TRUE);
run_ns_tagname_overwrite_test(text, result);
}
END_TEST
XML_SetStartElementHandler(parser, start_element_fail);
XML_SetStartNamespaceDeclHandler(parser, start_ns_clearing_start_element);
XML_UseParserAsHandlerArg(parser);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
XML_SetUserData(parser, (void *) callno);
p2 = XML_ExternalEntityParserCreate(parser, context, NULL);
- if (XML_Parse(p2, text, strlen(text), 1) == XML_STATUS_ERROR) {
+ if (XML_Parse(p2, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) {
xml_failure(p2);
return 0;
}
/* We actually need to set this handler to tickle this bug. */
XML_SetStartElementHandler(parser, dummy_start_element);
XML_SetUserData(parser, NULL);
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
}
END_TEST
+/* Regression test #3 for SF bug #673791. */
+START_TEST(test_ns_prefix_with_empty_uri_3)
+{
+ char *text =
+ "<!DOCTYPE doc [\n"
+ " <!ELEMENT doc EMPTY>\n"
+ " <!ATTLIST doc\n"
+ " xmlns:prefix CDATA ''>\n"
+ "]>\n"
+ "<doc/>";
+
+ expect_failure(text,
+ XML_ERROR_SYNTAX,
+ "Didn't report attr default setting NS w/ prefix to ''.");
+}
+END_TEST
+
+/* Regression test #4 for SF bug #673791. */
+START_TEST(test_ns_prefix_with_empty_uri_4)
+{
+ char *text =
+ "<!DOCTYPE doc [\n"
+ " <!ELEMENT prefix:doc EMPTY>\n"
+ " <!ATTLIST prefix:doc\n"
+ " xmlns:prefix CDATA 'http://xml.libexpat.org/'>\n"
+ "]>\n"
+ "<prefix:doc/>";
+ /* Packaged info expected by the end element handler;
+ the weird structuring lets us re-use the triplet_end_checker()
+ function also used for another test. */
+ char *elemstr[] = {
+ "http://xml.libexpat.org/ doc prefix"
+ };
+ XML_SetReturnNSTriplet(parser, XML_TRUE);
+ XML_SetUserData(parser, elemstr);
+ XML_SetEndElementHandler(parser, triplet_end_checker);
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+ xml_failure(parser);
+}
+END_TEST
+
START_TEST(test_ns_default_with_empty_uri)
{
char *text =
"<doc xmlns='http://xml.libexpat.org/'>\n"
" <e xmlns=''/>\n"
"</doc>";
- if (XML_Parse(parser, text, strlen(text), 1) == XML_STATUS_ERROR)
+ if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
xml_failure(parser);
}
END_TEST
tcase_add_test(tc_namespace, test_default_ns_from_ext_subset_and_ext_ge);
tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_1);
tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_2);
+ tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_3);
+ tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_4);
tcase_add_test(tc_namespace, test_ns_default_with_empty_uri);
return s;