|
|
@@ -6,8 +6,17 @@
|
|
|
\___/_/\_\ .__/ \__,_|\__|
|
|
|
|_| XML parser
|
|
|
|
|
|
- Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
|
|
|
- Copyright (c) 2000-2017 Expat development team
|
|
|
+ Copyright (c) 2001-2006 Fred L. Drake, Jr. <[email protected]>
|
|
|
+ Copyright (c) 2003 Greg Stein <[email protected]>
|
|
|
+ Copyright (c) 2005-2007 Steven Solie <[email protected]>
|
|
|
+ Copyright (c) 2005-2012 Karl Waclawek <[email protected]>
|
|
|
+ Copyright (c) 2016-2021 Sebastian Pipping <[email protected]>
|
|
|
+ Copyright (c) 2017-2018 Rhodri James <[email protected]>
|
|
|
+ Copyright (c) 2017 Joe Orton <[email protected]>
|
|
|
+ Copyright (c) 2017 José Gutiérrez de la Concha <[email protected]>
|
|
|
+ Copyright (c) 2018 Marco Maggi <[email protected]>
|
|
|
+ Copyright (c) 2019 David Loffredo <[email protected]>
|
|
|
+ Copyright (c) 2020 Tim Gates <[email protected]>
|
|
|
Licensed under the MIT license:
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
@@ -34,9 +43,7 @@
|
|
|
# undef NDEBUG /* because test suite relies on assert(...) at the moment */
|
|
|
#endif
|
|
|
|
|
|
-#ifdef HAVE_EXPAT_CONFIG_H
|
|
|
-# include <expat_config.h>
|
|
|
-#endif
|
|
|
+#include <expat_config.h>
|
|
|
|
|
|
#include <assert.h>
|
|
|
#include <stdlib.h>
|
|
|
@@ -45,34 +52,17 @@
|
|
|
#include <stddef.h> /* ptrdiff_t */
|
|
|
#include <ctype.h>
|
|
|
#include <limits.h>
|
|
|
-
|
|
|
-#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
|
|
|
-/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */
|
|
|
-# if defined(_WIN64)
|
|
|
-typedef __int64 intptr_t;
|
|
|
-# else
|
|
|
-typedef __int32 intptr_t;
|
|
|
-# endif
|
|
|
-typedef unsigned __int64 uint64_t;
|
|
|
-#else
|
|
|
-# include <stdint.h> /* intptr_t uint64_t */
|
|
|
-#endif
|
|
|
+#include <stdint.h> /* intptr_t uint64_t */
|
|
|
+#include <math.h> /* NAN, INFINITY, isnan */
|
|
|
|
|
|
#if ! defined(__cplusplus)
|
|
|
-# if defined(_MSC_VER) && (_MSC_VER <= 1700)
|
|
|
-/* for vs2012/11.0/1700 and earlier Visual Studio compilers */
|
|
|
-# define bool int
|
|
|
-# define false 0
|
|
|
-# define true 1
|
|
|
-# else
|
|
|
-# include <stdbool.h>
|
|
|
-# endif
|
|
|
+# include <stdbool.h>
|
|
|
#endif
|
|
|
|
|
|
#include "expat.h"
|
|
|
#include "chardata.h"
|
|
|
#include "structdata.h"
|
|
|
-#include "internal.h" /* for UNUSED_P only */
|
|
|
+#include "internal.h"
|
|
|
#include "minicheck.h"
|
|
|
#include "memcheck.h"
|
|
|
#include "siphash.h"
|
|
|
@@ -108,6 +98,16 @@ typedef unsigned __int64 uint64_t;
|
|
|
|
|
|
static XML_Parser g_parser = NULL;
|
|
|
|
|
|
+static void
|
|
|
+tcase_add_test__ifdef_xml_dtd(TCase *tc, tcase_test_function test) {
|
|
|
+#ifdef XML_DTD
|
|
|
+ tcase_add_test(tc, test);
|
|
|
+#else
|
|
|
+ UNUSED_P(tc);
|
|
|
+ UNUSED_P(test);
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
static void
|
|
|
basic_setup(void) {
|
|
|
g_parser = XML_ParserCreate(NULL);
|
|
|
@@ -1769,7 +1769,7 @@ START_TEST(test_not_standalone_handler_accept) {
|
|
|
XML_SetNotStandaloneHandler(g_parser, accept_not_standalone_handler);
|
|
|
run_ext_character_check(text, &test_data, XCS(""));
|
|
|
|
|
|
- /* Repeat wtihout the external entity handler */
|
|
|
+ /* Repeat without the external entity handler */
|
|
|
XML_ParserReset(g_parser, NULL);
|
|
|
XML_SetNotStandaloneHandler(g_parser, accept_not_standalone_handler);
|
|
|
run_character_check(text, XCS(""));
|
|
|
@@ -7049,17 +7049,39 @@ END_TEST
|
|
|
/* Test that too many colons are rejected */
|
|
|
START_TEST(test_ns_double_colon) {
|
|
|
const char *text = "<foo:e xmlns:foo='http://example.org/' foo:a:b='bar' />";
|
|
|
-
|
|
|
- expect_failure(text, XML_ERROR_INVALID_TOKEN,
|
|
|
- "Double colon in attribute name not faulted");
|
|
|
+ const enum XML_Status status
|
|
|
+ = _XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE);
|
|
|
+#ifdef XML_NS
|
|
|
+ if ((status == XML_STATUS_OK)
|
|
|
+ || (XML_GetErrorCode(g_parser) != XML_ERROR_INVALID_TOKEN)) {
|
|
|
+ fail("Double colon in attribute name not faulted"
|
|
|
+ " (despite active namespace support)");
|
|
|
+ }
|
|
|
+#else
|
|
|
+ if (status != XML_STATUS_OK) {
|
|
|
+ fail("Double colon in attribute name faulted"
|
|
|
+ " (despite inactive namespace support");
|
|
|
+ }
|
|
|
+#endif
|
|
|
}
|
|
|
END_TEST
|
|
|
|
|
|
START_TEST(test_ns_double_colon_element) {
|
|
|
const char *text = "<foo:bar:e xmlns:foo='http://example.org/' />";
|
|
|
-
|
|
|
- expect_failure(text, XML_ERROR_INVALID_TOKEN,
|
|
|
- "Double colon in element name not faulted");
|
|
|
+ const enum XML_Status status
|
|
|
+ = _XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE);
|
|
|
+#ifdef XML_NS
|
|
|
+ if ((status == XML_STATUS_OK)
|
|
|
+ || (XML_GetErrorCode(g_parser) != XML_ERROR_INVALID_TOKEN)) {
|
|
|
+ fail("Double colon in element name not faulted"
|
|
|
+ " (despite active namespace support)");
|
|
|
+ }
|
|
|
+#else
|
|
|
+ if (status != XML_STATUS_OK) {
|
|
|
+ fail("Double colon in element name faulted"
|
|
|
+ " (despite inactive namespace support");
|
|
|
+ }
|
|
|
+#endif
|
|
|
}
|
|
|
END_TEST
|
|
|
|
|
|
@@ -7329,7 +7351,7 @@ START_TEST(test_misc_version) {
|
|
|
fail("Version mismatch");
|
|
|
|
|
|
#if ! defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T)
|
|
|
- if (xcstrcmp(version_text, XCS("expat_2.2.9"))) /* needs bump on releases */
|
|
|
+ if (xcstrcmp(version_text, XCS("expat_2.4.1"))) /* needs bump on releases */
|
|
|
fail("XML_*_VERSION in expat.h out of sync?\n");
|
|
|
#else
|
|
|
/* If we have XML_UNICODE defined but not XML_UNICODE_WCHAR_T
|
|
|
@@ -7480,7 +7502,6 @@ START_TEST(test_misc_stop_during_end_handler_issue_240_2) {
|
|
|
}
|
|
|
END_TEST
|
|
|
|
|
|
-#ifdef XML_DTD
|
|
|
START_TEST(test_misc_deny_internal_entity_closing_doctype_issue_317) {
|
|
|
const char *const inputOne = "<!DOCTYPE d [\n"
|
|
|
"<!ENTITY % e ']><d/>'>\n"
|
|
|
@@ -7541,7 +7562,6 @@ START_TEST(test_misc_deny_internal_entity_closing_doctype_issue_317) {
|
|
|
}
|
|
|
}
|
|
|
END_TEST
|
|
|
-#endif
|
|
|
|
|
|
static void
|
|
|
alloc_setup(void) {
|
|
|
@@ -9817,6 +9837,15 @@ START_TEST(test_nsalloc_parse_buffer) {
|
|
|
|
|
|
/* Try a parse before the start of the world */
|
|
|
/* (Exercises new code path) */
|
|
|
+ if (XML_ParseBuffer(g_parser, 0, XML_FALSE) != XML_STATUS_ERROR)
|
|
|
+ fail("Pre-init XML_ParseBuffer not faulted");
|
|
|
+ if (XML_GetErrorCode(g_parser) != XML_ERROR_NO_BUFFER)
|
|
|
+ fail("Pre-init XML_ParseBuffer faulted for wrong reason");
|
|
|
+
|
|
|
+ buffer = XML_GetBuffer(g_parser, 1 /* any small number greater than 0 */);
|
|
|
+ if (buffer == NULL)
|
|
|
+ fail("Could not acquire parse buffer");
|
|
|
+
|
|
|
allocation_count = 0;
|
|
|
if (XML_ParseBuffer(g_parser, 0, XML_FALSE) != XML_STATUS_ERROR)
|
|
|
fail("Pre-init XML_ParseBuffer not faulted");
|
|
|
@@ -11197,6 +11226,389 @@ START_TEST(test_nsalloc_prefixed_element) {
|
|
|
}
|
|
|
END_TEST
|
|
|
|
|
|
+#if defined(XML_DTD)
|
|
|
+typedef enum XML_Status (*XmlParseFunction)(XML_Parser, const char *, int, int);
|
|
|
+
|
|
|
+struct AccountingTestCase {
|
|
|
+ const char *primaryText;
|
|
|
+ const char *firstExternalText; /* often NULL */
|
|
|
+ const char *secondExternalText; /* often NULL */
|
|
|
+ const unsigned long long expectedCountBytesIndirectExtra;
|
|
|
+ XML_Bool singleBytesWanted;
|
|
|
+};
|
|
|
+
|
|
|
+static int
|
|
|
+accounting_external_entity_ref_handler(XML_Parser parser,
|
|
|
+ const XML_Char *context,
|
|
|
+ const XML_Char *base,
|
|
|
+ const XML_Char *systemId,
|
|
|
+ const XML_Char *publicId) {
|
|
|
+ UNUSED_P(context);
|
|
|
+ UNUSED_P(base);
|
|
|
+ UNUSED_P(publicId);
|
|
|
+
|
|
|
+ const struct AccountingTestCase *const testCase
|
|
|
+ = (const struct AccountingTestCase *)XML_GetUserData(parser);
|
|
|
+
|
|
|
+ const char *externalText = NULL;
|
|
|
+ if (xcstrcmp(systemId, XCS("first.ent")) == 0) {
|
|
|
+ externalText = testCase->firstExternalText;
|
|
|
+ } else if (xcstrcmp(systemId, XCS("second.ent")) == 0) {
|
|
|
+ externalText = testCase->secondExternalText;
|
|
|
+ } else {
|
|
|
+ assert(! "systemId is neither \"first.ent\" nor \"second.ent\"");
|
|
|
+ }
|
|
|
+ assert(externalText);
|
|
|
+
|
|
|
+ XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
|
|
|
+ assert(entParser);
|
|
|
+
|
|
|
+ const XmlParseFunction xmlParseFunction
|
|
|
+ = testCase->singleBytesWanted ? _XML_Parse_SINGLE_BYTES : XML_Parse;
|
|
|
+
|
|
|
+ const enum XML_Status status = xmlParseFunction(
|
|
|
+ entParser, externalText, (int)strlen(externalText), XML_TRUE);
|
|
|
+
|
|
|
+ XML_ParserFree(entParser);
|
|
|
+ return status;
|
|
|
+}
|
|
|
+
|
|
|
+START_TEST(test_accounting_precision) {
|
|
|
+ const XML_Bool filled_later = XML_TRUE; /* value is arbitrary */
|
|
|
+ struct AccountingTestCase cases[] = {
|
|
|
+ {"<e/>", NULL, NULL, 0, 0},
|
|
|
+ {"<e></e>", NULL, NULL, 0, 0},
|
|
|
+
|
|
|
+ /* Attributes */
|
|
|
+ {"<e k1=\"v2\" k2=\"v2\"/>", NULL, NULL, 0, filled_later},
|
|
|
+ {"<e k1=\"v2\" k2=\"v2\"></e>", NULL, NULL, 0, 0},
|
|
|
+ {"<p:e xmlns:p=\"https://domain.invalid/\" />", NULL, NULL, 0,
|
|
|
+ filled_later},
|
|
|
+ {"<e k=\"&'><"\" />", NULL, NULL,
|
|
|
+ sizeof(XML_Char) * 5 /* number of predefined entites */, filled_later},
|
|
|
+ {"<e1 xmlns='https://example.org/'>\n"
|
|
|
+ " <e2 xmlns=''/>\n"
|
|
|
+ "</e1>",
|
|
|
+ NULL, NULL, 0, filled_later},
|
|
|
+
|
|
|
+ /* Text */
|
|
|
+ {"<e>text</e>", NULL, NULL, 0, filled_later},
|
|
|
+ {"<e1><e2>text1<e3/>text2</e2></e1>", NULL, NULL, 0, filled_later},
|
|
|
+ {"<e>&'><"</e>", NULL, NULL,
|
|
|
+ sizeof(XML_Char) * 5 /* number of predefined entites */, filled_later},
|
|
|
+ {"<e>A)</e>", NULL, NULL, 0, filled_later},
|
|
|
+
|
|
|
+ /* Prolog */
|
|
|
+ {"<?xml version=\"1.0\"?><root/>", NULL, NULL, 0, filled_later},
|
|
|
+
|
|
|
+ /* Whitespace */
|
|
|
+ {" <e1> <e2> </e2> </e1> ", NULL, NULL, 0, filled_later},
|
|
|
+ {"<e1 ><e2 /></e1 >", NULL, NULL, 0, filled_later},
|
|
|
+ {"<e1><e2 k = \"v\"/><e3 k = 'v'/></e1>", NULL, NULL, 0, filled_later},
|
|
|
+
|
|
|
+ /* Comments */
|
|
|
+ {"<!-- Comment --><e><!-- Comment --></e>", NULL, NULL, 0, filled_later},
|
|
|
+
|
|
|
+ /* Processing instructions */
|
|
|
+ {"<?xml-stylesheet type=\"text/xsl\" href=\"https://domain.invalid/\" media=\"all\"?><e/>",
|
|
|
+ NULL, NULL, 0, filled_later},
|
|
|
+ {"<?pi0?><?pi1 ?><?pi2 ?><!DOCTYPE r SYSTEM 'first.ent'><r/>",
|
|
|
+ "<?pi3?><!ENTITY % e1 SYSTEM 'second.ent'><?pi4?>%e1;<?pi5?>", "<?pi6?>",
|
|
|
+ 0, filled_later},
|
|
|
+
|
|
|
+ /* CDATA */
|
|
|
+ {"<e><![CDATA[one two three]]></e>", NULL, NULL, 0, filled_later},
|
|
|
+ /* The following is the essence of this OSS-Fuzz finding:
|
|
|
+ https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34302
|
|
|
+ https://oss-fuzz.com/testcase-detail/4860575394955264
|
|
|
+ */
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ "<!ENTITY e \"111<![CDATA[2 <= 2]]>333\">\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r>&e;</r>\n",
|
|
|
+ NULL, NULL, sizeof(XML_Char) * strlen("111<![CDATA[2 <= 2]]>333"),
|
|
|
+ filled_later},
|
|
|
+
|
|
|
+ /* Conditional sections */
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ "<!ENTITY % draft 'INCLUDE'>\n"
|
|
|
+ "<!ENTITY % final 'IGNORE'>\n"
|
|
|
+ "<!ENTITY % import SYSTEM \"first.ent\">\n"
|
|
|
+ "%import;\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r/>\n",
|
|
|
+ "<![%draft;[<!--1-->]]>\n"
|
|
|
+ "<![%final;[<!--22-->]]>",
|
|
|
+ NULL, sizeof(XML_Char) * (strlen("INCLUDE") + strlen("IGNORE")),
|
|
|
+ filled_later},
|
|
|
+
|
|
|
+ /* General entities */
|
|
|
+ {"<!DOCTYPE root [\n"
|
|
|
+ "<!ENTITY nine \"123456789\">\n"
|
|
|
+ "]>\n"
|
|
|
+ "<root>&nine;</root>",
|
|
|
+ NULL, NULL, sizeof(XML_Char) * strlen("123456789"), filled_later},
|
|
|
+ {"<!DOCTYPE root [\n"
|
|
|
+ "<!ENTITY nine \"123456789\">\n"
|
|
|
+ "]>\n"
|
|
|
+ "<root k1=\"&nine;\"/>",
|
|
|
+ NULL, NULL, sizeof(XML_Char) * strlen("123456789"), filled_later},
|
|
|
+ {"<!DOCTYPE root [\n"
|
|
|
+ "<!ENTITY nine \"123456789\">\n"
|
|
|
+ "<!ENTITY nine2 \"&nine;&nine;\">\n"
|
|
|
+ "]>\n"
|
|
|
+ "<root>&nine2;&nine2;&nine2;</root>",
|
|
|
+ NULL, NULL,
|
|
|
+ sizeof(XML_Char) * 3 /* calls to &nine2; */ * 2 /* calls to &nine; */
|
|
|
+ * (strlen("&nine;") + strlen("123456789")),
|
|
|
+ filled_later},
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ " <!ENTITY five SYSTEM 'first.ent'>\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r>&five;</r>",
|
|
|
+ "12345", NULL, 0, filled_later},
|
|
|
+
|
|
|
+ /* Parameter entities */
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ "<!ENTITY % comment \"<!---->\">\n"
|
|
|
+ "%comment;\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r/>",
|
|
|
+ NULL, NULL, sizeof(XML_Char) * strlen("<!---->"), filled_later},
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ "<!ENTITY % ninedef \"<!ENTITY nine "123456789">\">\n"
|
|
|
+ "%ninedef;\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r>&nine;</r>",
|
|
|
+ NULL, NULL,
|
|
|
+ sizeof(XML_Char)
|
|
|
+ * (strlen("<!ENTITY nine \"123456789\">") + strlen("123456789")),
|
|
|
+ filled_later},
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ "<!ENTITY % comment \"<!--1-->\">\n"
|
|
|
+ "<!ENTITY % comment2 \"%comment;<!--22-->%comment;\">\n"
|
|
|
+ "%comment2;\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r/>\n",
|
|
|
+ NULL, NULL,
|
|
|
+ sizeof(XML_Char)
|
|
|
+ * (strlen("%comment;<!--22-->%comment;") + 2 * strlen("<!--1-->")),
|
|
|
+ filled_later},
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ " <!ENTITY % five \"12345\">\n"
|
|
|
+ " <!ENTITY % five2def \"<!ENTITY five2 "[%five;][%five;]]]]">\">\n"
|
|
|
+ " %five2def;\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r>&five2;</r>",
|
|
|
+ NULL, NULL, /* from "%five2def;": */
|
|
|
+ sizeof(XML_Char)
|
|
|
+ * (strlen("<!ENTITY five2 \"[%five;][%five;]]]]\">")
|
|
|
+ + 2 /* calls to "%five;" */ * strlen("12345")
|
|
|
+ + /* from "&five2;": */ strlen("[12345][12345]]]]")),
|
|
|
+ filled_later},
|
|
|
+ {"<!DOCTYPE r SYSTEM \"first.ent\">\n"
|
|
|
+ "<r/>",
|
|
|
+ "<!ENTITY % comment '<!--1-->'>\n"
|
|
|
+ "<!ENTITY % comment2 '<!--22-->%comment;<!--22-->%comment;<!--22-->'>\n"
|
|
|
+ "%comment2;",
|
|
|
+ NULL,
|
|
|
+ sizeof(XML_Char)
|
|
|
+ * (strlen("<!--22-->%comment;<!--22-->%comment;<!--22-->")
|
|
|
+ + 2 /* calls to "%comment;" */ * strlen("<!---->")),
|
|
|
+ filled_later},
|
|
|
+ {"<!DOCTYPE r SYSTEM 'first.ent'>\n"
|
|
|
+ "<r/>",
|
|
|
+ "<!ENTITY % e1 PUBLIC 'foo' 'second.ent'>\n"
|
|
|
+ "<!ENTITY % e2 '<!--22-->%e1;<!--22-->'>\n"
|
|
|
+ "%e2;\n",
|
|
|
+ "<!--1-->", sizeof(XML_Char) * strlen("<!--22--><!--1--><!--22-->"),
|
|
|
+ filled_later},
|
|
|
+ {
|
|
|
+ "<!DOCTYPE r SYSTEM 'first.ent'>\n"
|
|
|
+ "<r/>",
|
|
|
+ "<!ENTITY % e1 SYSTEM 'second.ent'>\n"
|
|
|
+ "<!ENTITY % e2 '%e1;'>",
|
|
|
+ "<?xml version='1.0' encoding='utf-8'?>\n"
|
|
|
+ "hello\n"
|
|
|
+ "xml" /* without trailing newline! */,
|
|
|
+ 0,
|
|
|
+ filled_later,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "<!DOCTYPE r SYSTEM 'first.ent'>\n"
|
|
|
+ "<r/>",
|
|
|
+ "<!ENTITY % e1 SYSTEM 'second.ent'>\n"
|
|
|
+ "<!ENTITY % e2 '%e1;'>",
|
|
|
+ "<?xml version='1.0' encoding='utf-8'?>\n"
|
|
|
+ "hello\n"
|
|
|
+ "xml\n" /* with trailing newline! */,
|
|
|
+ 0,
|
|
|
+ filled_later,
|
|
|
+ },
|
|
|
+ {"<!DOCTYPE doc SYSTEM 'first.ent'>\n"
|
|
|
+ "<doc></doc>\n",
|
|
|
+ "<!ELEMENT doc EMPTY>\n"
|
|
|
+ "<!ENTITY % e1 SYSTEM 'second.ent'>\n"
|
|
|
+ "<!ENTITY % e2 '%e1;'>\n"
|
|
|
+ "%e1;\n",
|
|
|
+ "\xEF\xBB\xBF<!ATTLIST doc a1 CDATA 'value'>" /* UTF-8 BOM */,
|
|
|
+ strlen("\xEF\xBB\xBF<!ATTLIST doc a1 CDATA 'value'>"), filled_later},
|
|
|
+ {"<!DOCTYPE r [\n"
|
|
|
+ " <!ENTITY five SYSTEM 'first.ent'>\n"
|
|
|
+ "]>\n"
|
|
|
+ "<r>&five;</r>",
|
|
|
+ "\xEF\xBB\xBF" /* UTF-8 BOM */, NULL, 0, filled_later},
|
|
|
+ };
|
|
|
+
|
|
|
+ const size_t countCases = sizeof(cases) / sizeof(cases[0]);
|
|
|
+ size_t u = 0;
|
|
|
+ for (; u < countCases; u++) {
|
|
|
+ size_t v = 0;
|
|
|
+ for (; v < 2; v++) {
|
|
|
+ const XML_Bool singleBytesWanted = (v == 0) ? XML_FALSE : XML_TRUE;
|
|
|
+ const unsigned long long expectedCountBytesDirect
|
|
|
+ = strlen(cases[u].primaryText);
|
|
|
+ const unsigned long long expectedCountBytesIndirect
|
|
|
+ = (cases[u].firstExternalText ? strlen(cases[u].firstExternalText)
|
|
|
+ : 0)
|
|
|
+ + (cases[u].secondExternalText ? strlen(cases[u].secondExternalText)
|
|
|
+ : 0)
|
|
|
+ + cases[u].expectedCountBytesIndirectExtra;
|
|
|
+
|
|
|
+ XML_Parser parser = XML_ParserCreate(NULL);
|
|
|
+ XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
|
|
|
+ if (cases[u].firstExternalText) {
|
|
|
+ XML_SetExternalEntityRefHandler(parser,
|
|
|
+ accounting_external_entity_ref_handler);
|
|
|
+ XML_SetUserData(parser, (void *)&cases[u]);
|
|
|
+ cases[u].singleBytesWanted = singleBytesWanted;
|
|
|
+ }
|
|
|
+
|
|
|
+ const XmlParseFunction xmlParseFunction
|
|
|
+ = singleBytesWanted ? _XML_Parse_SINGLE_BYTES : XML_Parse;
|
|
|
+
|
|
|
+ enum XML_Status status
|
|
|
+ = xmlParseFunction(parser, cases[u].primaryText,
|
|
|
+ (int)strlen(cases[u].primaryText), XML_TRUE);
|
|
|
+ if (status != XML_STATUS_OK) {
|
|
|
+ _xml_failure(parser, __FILE__, __LINE__);
|
|
|
+ }
|
|
|
+
|
|
|
+ const unsigned long long actualCountBytesDirect
|
|
|
+ = testingAccountingGetCountBytesDirect(parser);
|
|
|
+ const unsigned long long actualCountBytesIndirect
|
|
|
+ = testingAccountingGetCountBytesIndirect(parser);
|
|
|
+
|
|
|
+ XML_ParserFree(parser);
|
|
|
+
|
|
|
+ if (actualCountBytesDirect != expectedCountBytesDirect) {
|
|
|
+ fprintf(
|
|
|
+ stderr,
|
|
|
+ "Document " EXPAT_FMT_SIZE_T("") " of " EXPAT_FMT_SIZE_T("") ", %s: Expected " EXPAT_FMT_ULL(
|
|
|
+ "") " count direct bytes, got " EXPAT_FMT_ULL("") " instead.\n",
|
|
|
+ u + 1, countCases, singleBytesWanted ? "single bytes" : "chunks",
|
|
|
+ expectedCountBytesDirect, actualCountBytesDirect);
|
|
|
+ fail("Count of direct bytes is off");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (actualCountBytesIndirect != expectedCountBytesIndirect) {
|
|
|
+ fprintf(
|
|
|
+ stderr,
|
|
|
+ "Document " EXPAT_FMT_SIZE_T("") " of " EXPAT_FMT_SIZE_T("") ", %s: Expected " EXPAT_FMT_ULL(
|
|
|
+ "") " count indirect bytes, got " EXPAT_FMT_ULL("") " instead.\n",
|
|
|
+ u + 1, countCases, singleBytesWanted ? "single bytes" : "chunks",
|
|
|
+ expectedCountBytesIndirect, actualCountBytesIndirect);
|
|
|
+ fail("Count of indirect bytes is off");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+END_TEST
|
|
|
+
|
|
|
+START_TEST(test_billion_laughs_attack_protection_api) {
|
|
|
+ XML_Parser parserWithoutParent = XML_ParserCreate(NULL);
|
|
|
+ XML_Parser parserWithParent
|
|
|
+ = XML_ExternalEntityParserCreate(parserWithoutParent, NULL, NULL);
|
|
|
+ if (parserWithoutParent == NULL)
|
|
|
+ fail("parserWithoutParent is NULL");
|
|
|
+ if (parserWithParent == NULL)
|
|
|
+ fail("parserWithParent is NULL");
|
|
|
+
|
|
|
+ // XML_SetBillionLaughsAttackProtectionMaximumAmplification, error cases
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(NULL, 123.0f)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with NULL parser is NOT supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(parserWithParent,
|
|
|
+ 123.0f)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with non-root parser is NOT supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(
|
|
|
+ parserWithoutParent, NAN)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with NaN limit is NOT supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(
|
|
|
+ parserWithoutParent, -1.0f)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with negative limit is NOT supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(
|
|
|
+ parserWithoutParent, 0.9f)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with positive limit <1.0 is NOT supposed to succeed");
|
|
|
+
|
|
|
+ // XML_SetBillionLaughsAttackProtectionMaximumAmplification, success cases
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(
|
|
|
+ parserWithoutParent, 1.0f)
|
|
|
+ == XML_FALSE)
|
|
|
+ fail("Call with positive limit >=1.0 is supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(
|
|
|
+ parserWithoutParent, 123456.789f)
|
|
|
+ == XML_FALSE)
|
|
|
+ fail("Call with positive limit >=1.0 is supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionMaximumAmplification(
|
|
|
+ parserWithoutParent, INFINITY)
|
|
|
+ == XML_FALSE)
|
|
|
+ fail("Call with positive limit >=1.0 is supposed to succeed");
|
|
|
+
|
|
|
+ // XML_SetBillionLaughsAttackProtectionActivationThreshold, error cases
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionActivationThreshold(NULL, 123)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with NULL parser is NOT supposed to succeed");
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionActivationThreshold(parserWithParent,
|
|
|
+ 123)
|
|
|
+ == XML_TRUE)
|
|
|
+ fail("Call with non-root parser is NOT supposed to succeed");
|
|
|
+
|
|
|
+ // XML_SetBillionLaughsAttackProtectionActivationThreshold, success cases
|
|
|
+ if (XML_SetBillionLaughsAttackProtectionActivationThreshold(
|
|
|
+ parserWithoutParent, 123)
|
|
|
+ == XML_FALSE)
|
|
|
+ fail("Call with non-NULL parentless parser is supposed to succeed");
|
|
|
+
|
|
|
+ XML_ParserFree(parserWithParent);
|
|
|
+ XML_ParserFree(parserWithoutParent);
|
|
|
+}
|
|
|
+END_TEST
|
|
|
+
|
|
|
+START_TEST(test_helper_unsigned_char_to_printable) {
|
|
|
+ // Smoke test
|
|
|
+ unsigned char uc = 0;
|
|
|
+ for (; uc < (unsigned char)-1; uc++) {
|
|
|
+ const char *const printable = unsignedCharToPrintable(uc);
|
|
|
+ if (printable == NULL)
|
|
|
+ fail("unsignedCharToPrintable returned NULL");
|
|
|
+ if (strlen(printable) < (size_t)1)
|
|
|
+ fail("unsignedCharToPrintable returned empty string");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Two concrete samples
|
|
|
+ if (strcmp(unsignedCharToPrintable('A'), "A") != 0)
|
|
|
+ fail("unsignedCharToPrintable result mistaken");
|
|
|
+ if (strcmp(unsignedCharToPrintable('\\'), "\\\\") != 0)
|
|
|
+ fail("unsignedCharToPrintable result mistaken");
|
|
|
+}
|
|
|
+END_TEST
|
|
|
+#endif // defined(XML_DTD)
|
|
|
+
|
|
|
static Suite *
|
|
|
make_suite(void) {
|
|
|
Suite *s = suite_create("basic");
|
|
|
@@ -11205,6 +11617,9 @@ make_suite(void) {
|
|
|
TCase *tc_misc = tcase_create("miscellaneous tests");
|
|
|
TCase *tc_alloc = tcase_create("allocation tests");
|
|
|
TCase *tc_nsalloc = tcase_create("namespace allocation tests");
|
|
|
+#if defined(XML_DTD)
|
|
|
+ TCase *tc_accounting = tcase_create("accounting tests");
|
|
|
+#endif
|
|
|
|
|
|
suite_add_tcase(s, tc_basic);
|
|
|
tcase_add_checked_fixture(tc_basic, basic_setup, basic_teardown);
|
|
|
@@ -11259,13 +11674,14 @@ make_suite(void) {
|
|
|
test_wfc_undeclared_entity_with_external_subset_standalone);
|
|
|
tcase_add_test(tc_basic, test_entity_with_external_subset_unless_standalone);
|
|
|
tcase_add_test(tc_basic, test_wfc_no_recursive_entity_refs);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_set_encoding);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_no_handler);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_set_bom);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_bad_encoding);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_bad_encoding_2);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_invalid_parse);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_invalid_suspended_parse);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_set_encoding);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_no_handler);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_set_bom);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_bad_encoding);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_bad_encoding_2);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_invalid_parse);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic,
|
|
|
+ test_ext_entity_invalid_suspended_parse);
|
|
|
tcase_add_test(tc_basic, test_dtd_default_handling);
|
|
|
tcase_add_test(tc_basic, test_dtd_attr_handling);
|
|
|
tcase_add_test(tc_basic, test_empty_ns_without_namespaces);
|
|
|
@@ -11277,25 +11693,22 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_good_cdata_utf16);
|
|
|
tcase_add_test(tc_basic, test_good_cdata_utf16_le);
|
|
|
tcase_add_test(tc_basic, test_long_cdata_utf16);
|
|
|
-#ifndef XML_MIN_SIZE /* FIXME workaround -DXML_MIN_SIZE + ASan (issue #332) */
|
|
|
tcase_add_test(tc_basic, test_multichar_cdata_utf16);
|
|
|
-#endif
|
|
|
tcase_add_test(tc_basic, test_utf16_bad_surrogate_pair);
|
|
|
tcase_add_test(tc_basic, test_bad_cdata);
|
|
|
-#ifndef XML_MIN_SIZE /* FIXME workaround -DXML_MIN_SIZE + ASan (issue #332) */
|
|
|
tcase_add_test(tc_basic, test_bad_cdata_utf16);
|
|
|
-#endif
|
|
|
tcase_add_test(tc_basic, test_stop_parser_between_cdata_calls);
|
|
|
tcase_add_test(tc_basic, test_suspend_parser_between_cdata_calls);
|
|
|
tcase_add_test(tc_basic, test_memory_allocation);
|
|
|
tcase_add_test(tc_basic, test_default_current);
|
|
|
tcase_add_test(tc_basic, test_dtd_elements);
|
|
|
- tcase_add_test(tc_basic, test_set_foreign_dtd);
|
|
|
- tcase_add_test(tc_basic, test_foreign_dtd_not_standalone);
|
|
|
- tcase_add_test(tc_basic, test_invalid_foreign_dtd);
|
|
|
- tcase_add_test(tc_basic, test_foreign_dtd_with_doctype);
|
|
|
- tcase_add_test(tc_basic, test_foreign_dtd_without_external_subset);
|
|
|
- tcase_add_test(tc_basic, test_empty_foreign_dtd);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_set_foreign_dtd);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_foreign_dtd_not_standalone);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_invalid_foreign_dtd);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_foreign_dtd_with_doctype);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic,
|
|
|
+ test_foreign_dtd_without_external_subset);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_empty_foreign_dtd);
|
|
|
tcase_add_test(tc_basic, test_set_base);
|
|
|
tcase_add_test(tc_basic, test_attributes);
|
|
|
tcase_add_test(tc_basic, test_reset_in_entity);
|
|
|
@@ -11312,8 +11725,8 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_trailing_rsqb);
|
|
|
tcase_add_test(tc_basic, test_ext_entity_trailing_rsqb);
|
|
|
tcase_add_test(tc_basic, test_ext_entity_good_cdata);
|
|
|
- tcase_add_test(tc_basic, test_user_parameters);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_ref_parameter);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_user_parameters);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_ref_parameter);
|
|
|
tcase_add_test(tc_basic, test_empty_parse);
|
|
|
tcase_add_test(tc_basic, test_get_buffer_1);
|
|
|
tcase_add_test(tc_basic, test_get_buffer_2);
|
|
|
@@ -11321,25 +11734,26 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_byte_info_at_error);
|
|
|
tcase_add_test(tc_basic, test_byte_info_at_cdata);
|
|
|
tcase_add_test(tc_basic, test_predefined_entities);
|
|
|
- tcase_add_test(tc_basic, test_invalid_tag_in_dtd);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_invalid_tag_in_dtd);
|
|
|
tcase_add_test(tc_basic, test_not_predefined_entities);
|
|
|
- tcase_add_test(tc_basic, test_ignore_section);
|
|
|
- tcase_add_test(tc_basic, test_ignore_section_utf16);
|
|
|
- tcase_add_test(tc_basic, test_ignore_section_utf16_be);
|
|
|
- tcase_add_test(tc_basic, test_bad_ignore_section);
|
|
|
- tcase_add_test(tc_basic, test_external_entity_values);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_not_standalone);
|
|
|
- tcase_add_test(tc_basic, test_ext_entity_value_abort);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ignore_section);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ignore_section_utf16);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ignore_section_utf16_be);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_bad_ignore_section);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_external_entity_values);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_not_standalone);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_ext_entity_value_abort);
|
|
|
tcase_add_test(tc_basic, test_bad_public_doctype);
|
|
|
tcase_add_test(tc_basic, test_attribute_enum_value);
|
|
|
tcase_add_test(tc_basic, test_predefined_entity_redefinition);
|
|
|
- tcase_add_test(tc_basic, test_dtd_stop_processing);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_dtd_stop_processing);
|
|
|
tcase_add_test(tc_basic, test_public_notation_no_sysid);
|
|
|
tcase_add_test(tc_basic, test_nested_groups);
|
|
|
tcase_add_test(tc_basic, test_group_choice);
|
|
|
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__ifdef_xml_dtd(tc_basic, test_skipped_parameter_entity);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic,
|
|
|
+ test_recursive_external_parameter_entity);
|
|
|
tcase_add_test(tc_basic, test_undefined_ext_entity_in_external_dtd);
|
|
|
tcase_add_test(tc_basic, test_suspend_xdecl);
|
|
|
tcase_add_test(tc_basic, test_abort_epilog);
|
|
|
@@ -11349,9 +11763,9 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_unfinished_epilog);
|
|
|
tcase_add_test(tc_basic, test_partial_char_in_epilog);
|
|
|
tcase_add_test(tc_basic, test_hash_collision);
|
|
|
- tcase_add_test(tc_basic, test_suspend_resume_internal_entity);
|
|
|
- tcase_add_test(tc_basic, test_resume_entity_with_syntax_error);
|
|
|
- tcase_add_test(tc_basic, test_suspend_resume_parameter_entity);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_suspend_resume_internal_entity);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_resume_entity_with_syntax_error);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_suspend_resume_parameter_entity);
|
|
|
tcase_add_test(tc_basic, test_restart_on_error);
|
|
|
tcase_add_test(tc_basic, test_reject_lt_in_attribute_value);
|
|
|
tcase_add_test(tc_basic, test_reject_unfinished_param_in_att_value);
|
|
|
@@ -11360,7 +11774,7 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_skipped_external_entity);
|
|
|
tcase_add_test(tc_basic, test_skipped_null_loaded_ext_entity);
|
|
|
tcase_add_test(tc_basic, test_skipped_unloaded_ext_entity);
|
|
|
- tcase_add_test(tc_basic, test_param_entity_with_trailing_cr);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_param_entity_with_trailing_cr);
|
|
|
tcase_add_test(tc_basic, test_invalid_character_entity);
|
|
|
tcase_add_test(tc_basic, test_invalid_character_entity_2);
|
|
|
tcase_add_test(tc_basic, test_invalid_character_entity_3);
|
|
|
@@ -11403,7 +11817,7 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_utf16_attribute);
|
|
|
tcase_add_test(tc_basic, test_utf16_second_attr);
|
|
|
tcase_add_test(tc_basic, test_attr_after_solidus);
|
|
|
- tcase_add_test(tc_basic, test_utf16_pe);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_utf16_pe);
|
|
|
tcase_add_test(tc_basic, test_bad_attr_desc_keyword);
|
|
|
tcase_add_test(tc_basic, test_bad_attr_desc_keyword_utf16);
|
|
|
tcase_add_test(tc_basic, test_bad_doctype);
|
|
|
@@ -11411,11 +11825,11 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_basic, test_bad_doctype_plus);
|
|
|
tcase_add_test(tc_basic, test_bad_doctype_star);
|
|
|
tcase_add_test(tc_basic, test_bad_doctype_query);
|
|
|
- tcase_add_test(tc_basic, test_unknown_encoding_bad_ignore);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_unknown_encoding_bad_ignore);
|
|
|
tcase_add_test(tc_basic, test_entity_in_utf16_be_attr);
|
|
|
tcase_add_test(tc_basic, test_entity_in_utf16_le_attr);
|
|
|
- tcase_add_test(tc_basic, test_entity_public_utf16_be);
|
|
|
- tcase_add_test(tc_basic, test_entity_public_utf16_le);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_entity_public_utf16_be);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_basic, test_entity_public_utf16_le);
|
|
|
tcase_add_test(tc_basic, test_short_doctype);
|
|
|
tcase_add_test(tc_basic, test_short_doctype_2);
|
|
|
tcase_add_test(tc_basic, test_short_doctype_3);
|
|
|
@@ -11434,7 +11848,8 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_namespace, test_ns_tagname_overwrite);
|
|
|
tcase_add_test(tc_namespace, test_ns_tagname_overwrite_triplet);
|
|
|
tcase_add_test(tc_namespace, test_start_ns_clears_start_element);
|
|
|
- tcase_add_test(tc_namespace, test_default_ns_from_ext_subset_and_ext_ge);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(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);
|
|
|
@@ -11475,10 +11890,8 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_misc, test_misc_utf16le);
|
|
|
tcase_add_test(tc_misc, test_misc_stop_during_end_handler_issue_240_1);
|
|
|
tcase_add_test(tc_misc, test_misc_stop_during_end_handler_issue_240_2);
|
|
|
-#ifdef XML_DTD
|
|
|
- tcase_add_test(tc_misc,
|
|
|
- test_misc_deny_internal_entity_closing_doctype_issue_317);
|
|
|
-#endif
|
|
|
+ tcase_add_test__ifdef_xml_dtd(
|
|
|
+ tc_misc, test_misc_deny_internal_entity_closing_doctype_issue_317);
|
|
|
|
|
|
suite_add_tcase(s, tc_alloc);
|
|
|
tcase_add_checked_fixture(tc_alloc, alloc_setup, alloc_teardown);
|
|
|
@@ -11489,45 +11902,49 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_alloc, test_alloc_parse_pi_3);
|
|
|
tcase_add_test(tc_alloc, test_alloc_parse_comment);
|
|
|
tcase_add_test(tc_alloc, test_alloc_parse_comment_2);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_create_external_parser);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_run_external_parser);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_dtd_copy_default_atts);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_external_entity);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_ext_entity_set_encoding);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_internal_entity);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_dtd_default_handling);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_create_external_parser);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_run_external_parser);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_dtd_copy_default_atts);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_external_entity);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_ext_entity_set_encoding);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_internal_entity);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_dtd_default_handling);
|
|
|
tcase_add_test(tc_alloc, test_alloc_explicit_encoding);
|
|
|
tcase_add_test(tc_alloc, test_alloc_set_base);
|
|
|
tcase_add_test(tc_alloc, test_alloc_realloc_buffer);
|
|
|
tcase_add_test(tc_alloc, test_alloc_ext_entity_realloc_buffer);
|
|
|
tcase_add_test(tc_alloc, test_alloc_realloc_many_attributes);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_public_entity_value);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_subst_public_entity_value);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_public_entity_value);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc,
|
|
|
+ test_alloc_realloc_subst_public_entity_value);
|
|
|
tcase_add_test(tc_alloc, test_alloc_parse_public_doctype);
|
|
|
tcase_add_test(tc_alloc, test_alloc_parse_public_doctype_long_name);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_set_foreign_dtd);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_attribute_enum_value);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_attribute_enum_value);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_implied_attribute);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_default_attribute);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_set_foreign_dtd);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_attribute_enum_value);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc,
|
|
|
+ test_alloc_realloc_attribute_enum_value);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_realloc_implied_attribute);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_realloc_default_attribute);
|
|
|
tcase_add_test(tc_alloc, test_alloc_notation);
|
|
|
tcase_add_test(tc_alloc, test_alloc_public_notation);
|
|
|
tcase_add_test(tc_alloc, test_alloc_system_notation);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_nested_groups);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_nested_groups);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_nested_groups);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_realloc_nested_groups);
|
|
|
tcase_add_test(tc_alloc, test_alloc_large_group);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_group_choice);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_realloc_group_choice);
|
|
|
tcase_add_test(tc_alloc, test_alloc_pi_in_epilog);
|
|
|
tcase_add_test(tc_alloc, test_alloc_comment_in_epilog);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_long_attribute_value);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc,
|
|
|
+ test_alloc_realloc_long_attribute_value);
|
|
|
tcase_add_test(tc_alloc, test_alloc_attribute_whitespace);
|
|
|
tcase_add_test(tc_alloc, test_alloc_attribute_predefined_entity);
|
|
|
tcase_add_test(tc_alloc, test_alloc_long_attr_default_with_char_ref);
|
|
|
tcase_add_test(tc_alloc, test_alloc_long_attr_value);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_nested_entities);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_param_entity_newline);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_ce_extends_pe);
|
|
|
- tcase_add_test(tc_alloc, test_alloc_realloc_attributes);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_nested_entities);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc,
|
|
|
+ test_alloc_realloc_param_entity_newline);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_realloc_ce_extends_pe);
|
|
|
+ tcase_add_test__ifdef_xml_dtd(tc_alloc, test_alloc_realloc_attributes);
|
|
|
tcase_add_test(tc_alloc, test_alloc_long_doc_name);
|
|
|
tcase_add_test(tc_alloc, test_alloc_long_base);
|
|
|
tcase_add_test(tc_alloc, test_alloc_long_public_id);
|
|
|
@@ -11563,6 +11980,13 @@ make_suite(void) {
|
|
|
tcase_add_test(tc_nsalloc, test_nsalloc_long_systemid_in_ext);
|
|
|
tcase_add_test(tc_nsalloc, test_nsalloc_prefixed_element);
|
|
|
|
|
|
+#if defined(XML_DTD)
|
|
|
+ suite_add_tcase(s, tc_accounting);
|
|
|
+ tcase_add_test(tc_accounting, test_accounting_precision);
|
|
|
+ tcase_add_test(tc_accounting, test_billion_laughs_attack_protection_api);
|
|
|
+ tcase_add_test(tc_accounting, test_helper_unsigned_char_to_printable);
|
|
|
+#endif
|
|
|
+
|
|
|
return s;
|
|
|
}
|
|
|
|