diff options
author | Stefan Eissing <icing@apache.org> | 2022-04-06 11:17:42 +0200 |
---|---|---|
committer | Stefan Eissing <icing@apache.org> | 2022-04-06 11:17:42 +0200 |
commit | a4ea0e7799cc1bb63e5406cd427f09d668cedfae (patch) | |
tree | 19f8e1015613cafdcb9d35fbe8721eb26e869134 /test/unit | |
parent | * Report a broken backend in case reading the response line failed on the (diff) | |
download | apache2-a4ea0e7799cc1bb63e5406cd427f09d668cedfae.tar.xz apache2-a4ea0e7799cc1bb63e5406cd427f09d668cedfae.zip |
*) core: make ap_escape_quotes() work correctly on strings
with more than MAX_INT/2 characters, counting quotes double.
Credit to <generalbugs@zippenhop.com> for finding this.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1899609 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | test/unit/util.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/util.c b/test/unit/util.c index 5cadfd89ba..c9dec41a18 100644 --- a/test/unit/util.c +++ b/test/unit/util.c @@ -79,6 +79,41 @@ HTTPD_START_LOOP_TEST(find_token_correctly_parses_token_list, ap_test_token_case } END_TEST + +/* + * ap_escape_quotes() + */ + +struct ap_escape_quotes_case { + const char *input; + const char *expected; +}; + +#define ESCQ "\\\"" + +const struct ap_escape_quotes_case ap_test_escape_quotes_cases[] = { + { "one", "one" }, + { "o\"ne", "o"ESCQ"ne" }, + { "o"ESCQ"ne", "o"ESCQ"ne" }, + { "one\\", "one\\" }, + { "o\\ne", "o\\ne" }, + { "o\\"ESCQ"ne", "o\\\\"ESCQ"ne" }, /* 1st \ escapes 2nd, following '"' needs \ */ +}; + +const size_t ap_test_escape_quotes_cases_len = sizeof(ap_test_escape_quotes_cases) / + sizeof(ap_test_escape_quotes_cases[0]); + +HTTPD_START_LOOP_TEST(check_escape_quotes, ap_test_escape_quotes_cases_len) +{ + const struct ap_escape_quotes_case *c = &ap_test_escape_quotes_cases[_i]; + const char *result; + + result = ap_escape_quotes(g_pool, c->input); + ck_assert_str_eq(result, c->expected); +} +END_TEST + + /* * Test Case Boilerplate */ |