summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2014-04-25 10:39:23 +0000
committerGraham Leggett <minfrin@apache.org>2014-04-25 10:39:23 +0000
commit2e06f779e45a0fab5ee8567f46fc33783e6c703c (patch)
tree638d0dcda676f0f6481fd8d2ab7ade37e1b9f62f /test
parent14e59722ff010baf4998c6d0cff11632279ba8a8 (diff)
downloadapr-2e06f779e45a0fab5ee8567f46fc33783e6c703c.tar.gz
Backport from trunk:
Add apr_escape_ldap() and apr_pescape_ldap(), escaping characters as described by RFC4514 and RFC4515 respectively. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1589981 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/testescape.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/testescape.c b/test/testescape.c
index 323ff5618..66452274d 100644
--- a/test/testescape.c
+++ b/test/testescape.c
@@ -262,6 +262,42 @@ static void test_escape(abts_case *tc, void *data)
apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%" APR_SIZE_T_FMT ")", len, (apr_size_t)4),
(len == 4));
+ src = "Parens R Us (for all your parenthetical needs) plus asterisk* \"+,;<>\\";
+ target = "Parens R Us (for all your parenthetical needs) plus asterisk* \\22\\2b\\2c\\3b\\3c\\3e\\5c";
+ dest = apr_pescape_ldap(pool, src, APR_ESCAPE_STRING, APR_ESCAPE_LDAP_DN);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "ldap escaped (%s) does not match expected output (%s)",
+ dest, target),
+ (strcmp(dest, target) == 0));
+ apr_escape_ldap(NULL, src, APR_ESCAPE_STRING, APR_ESCAPE_LDAP_DN, &len);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%" APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
+ (len == strlen(dest) + 1));
+
+ src = "Parens R Us (for all your parenthetical needs) plus asterisk* \"+,;<>\\";
+ target = "Parens R Us \\28for all your parenthetical needs\\29 plus asterisk\\2a \"+,;<>\\5c";
+ dest = apr_pescape_ldap(pool, src, APR_ESCAPE_STRING, APR_ESCAPE_LDAP_FILTER);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "ldap escaped (%s) does not match expected output (%s)",
+ dest, target),
+ (strcmp(dest, target) == 0));
+ apr_escape_ldap(NULL, src, APR_ESCAPE_STRING, APR_ESCAPE_LDAP_FILTER, &len);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%" APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
+ (len == strlen(dest) + 1));
+
+ src = "Parens R Us (for all your parenthetical needs) plus asterisk* \"+,;<>\\";
+ target = "Parens R Us \\28for all your parenthetical needs\\29 plus asterisk\\2a \\22\\2b\\2c\\3b\\3c\\3e\\5c";
+ dest = apr_pescape_ldap(pool, src, APR_ESCAPE_STRING, APR_ESCAPE_LDAP_ALL);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "ldap escaped (%s) does not match expected output (%s)",
+ dest, target),
+ (strcmp(dest, target) == 0));
+ apr_escape_ldap(NULL, src, APR_ESCAPE_STRING, APR_ESCAPE_LDAP_ALL, &len);
+ ABTS_ASSERT(tc,
+ apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%" APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
+ (len == strlen(dest) + 1));
+
apr_pool_destroy(pool);
}