Skip to content

Commit

Permalink
Add a few tests on XML escaping.
Browse files Browse the repository at this point in the history
* subversion/tests/libsvn_subr/xml-test.c
  (test_xml_simple_cdata_escape, test_xml_simple_attr_escape): New tests.
  (test_funcs): Run these tests.


git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1922620 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rinrab committed Dec 21, 2024
1 parent dc7fe2f commit 8f4a664
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions subversion/tests/libsvn_subr/xml-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,26 @@ test_xml_parse_stream_invalid_xml(apr_pool_t *pool)
return SVN_NO_ERROR;
}

static svn_error_t *
test_xml_simple_cdata_escape(apr_pool_t *pool)
{
svn_stringbuf_t *str = svn_stringbuf_create_empty(pool);
svn_xml_escape_cdata_cstring(&str, "safetext <nonsafe&amp;>", pool);
SVN_TEST_STRING_ASSERT(str->data, "safetext &lt;nonsafe&amp;amp;&gt;");

return SVN_NO_ERROR;
}

static svn_error_t *
test_xml_simple_attr_escape(apr_pool_t *pool)
{
svn_stringbuf_t *str = svn_stringbuf_create_empty(pool);
svn_xml_escape_attr_cstring(&str, "safetext <nonsafe&amp;>", pool);
SVN_TEST_STRING_ASSERT(str->data, "safetext &lt;nonsafe&amp;amp;&gt;");

return SVN_NO_ERROR;
}

/* The test table. */
static int max_threads = 1;

Expand All @@ -403,6 +423,10 @@ static struct svn_test_descriptor_t test_funcs[] =
"test XML's svn_stream_t wrapper"),
SVN_TEST_PASS2(test_xml_parse_stream_invalid_xml,
"test XML's svn_stream_t wrapper for invalid XML"),
SVN_TEST_PASS2(test_xml_simple_cdata_escape,
"simple XML cdata escaping test"),
SVN_TEST_PASS2(test_xml_simple_attr_escape,
"simple XML attribute escaping test"),
SVN_TEST_NULL
};

Expand Down

0 comments on commit 8f4a664

Please sign in to comment.