diff options
author | Graham Leggett <minfrin@apache.org> | 2014-04-21 17:45:58 +0000 |
---|---|---|
committer | Graham Leggett <minfrin@apache.org> | 2014-04-21 17:45:58 +0000 |
commit | 882e7b8852fd4af3decd4c93fd895155a5c25c95 (patch) | |
tree | 636100248ba3547f2661b93ef9487d4aca12e476 /encoding | |
parent | d81ecb2730b3545f544016f1d9411cc4568b7bef (diff) | |
download | apr-882e7b8852fd4af3decd4c93fd895155a5c25c95.tar.gz |
Split the ability to filter LDAP escape sequences into DN escaping or filter
escaping, allowing the option to escape both at the same time.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1588937 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'encoding')
-rw-r--r-- | encoding/apr_escape.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/encoding/apr_escape.c b/encoding/apr_escape.c index 33705c739..eda467593 100644 --- a/encoding/apr_escape.c +++ b/encoding/apr_escape.c @@ -1181,7 +1181,7 @@ APR_DECLARE(const void *) apr_punescape_hex(apr_pool_t *p, const char *str, } APR_DECLARE(apr_status_t) apr_escape_ldap(char *escaped, const void *str, - apr_ssize_t slen, apr_size_t *len) + apr_ssize_t slen, int flags, apr_size_t *len) { apr_size_t size = 1; int found = 0; @@ -1192,7 +1192,8 @@ APR_DECLARE(apr_status_t) apr_escape_ldap(char *escaped, const void *str, if (s) { if (d) { while (((c = *s) && slen) || (slen > 0)) { - if (TEST_CHAR(c, T_ESCAPE_LDAP)) { + if (((flags & APR_ESCAPE_LDAP_DN) && TEST_CHAR(c, T_ESCAPE_LDAP_DN)) + || ((flags & APR_ESCAPE_LDAP_FILTER) && TEST_CHAR(c, T_ESCAPE_LDAP_FILTER))) { d = c2x(c, '\\', d); size += 2; found = 1; @@ -1208,7 +1209,8 @@ APR_DECLARE(apr_status_t) apr_escape_ldap(char *escaped, const void *str, } else { while (((c = *s) && slen) || (slen > 0)) { - if (TEST_CHAR(c, T_ESCAPE_LDAP)) { + if (((flags & APR_ESCAPE_LDAP_DN) && TEST_CHAR(c, T_ESCAPE_LDAP_DN)) + || ((flags & APR_ESCAPE_LDAP_FILTER) && TEST_CHAR(c, T_ESCAPE_LDAP_FILTER))) { size += 2; found = 1; } @@ -1229,14 +1231,15 @@ APR_DECLARE(apr_status_t) apr_escape_ldap(char *escaped, const void *str, return APR_SUCCESS; } -APR_DECLARE(const char *) apr_pescape_ldap(apr_pool_t *p, const void *src, apr_ssize_t srclen) +APR_DECLARE(const char *) apr_pescape_ldap(apr_pool_t *p, const void *src, + apr_ssize_t srclen, int flags) { apr_size_t len; - switch (apr_escape_ldap(NULL, src, srclen, &len)) { + switch (apr_escape_ldap(NULL, src, srclen, flags, &len)) { case APR_SUCCESS: { char *encoded = apr_palloc(p, len); - apr_escape_ldap(encoded, src, srclen, NULL); + apr_escape_ldap(encoded, src, srclen, flags, NULL); return encoded; } case APR_NOTFOUND: { |