diff options
author | Steve Holme <steve_holme@hotmail.com> | 2015-01-03 20:58:29 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2015-01-04 15:16:22 +0000 |
commit | 84143dc57d8532b65dcac3aa0e144e0bf81843d2 (patch) | |
tree | 223e4026a48df0b3615800e336724a2070de333e /lib/ldap.c | |
parent | 747bad7c09972298648e0ff5143de66b874ee612 (diff) | |
download | curl-84143dc57d8532b65dcac3aa0e144e0bf81843d2.tar.gz |
ldap: Fixed support for Unicode filter in Win32 search call
Diffstat (limited to 'lib/ldap.c')
-rw-r--r-- | lib/ldap.c | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/lib/ldap.c b/lib/ldap.c index 680e4d774..70b9a1cac 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -90,7 +90,12 @@ typedef struct { char **lud_attrs; #endif int lud_scope; +#if defined(CURL_LDAP_WIN) && \ + (defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI)) + TCHAR *lud_filter; +#else char *lud_filter; +#endif; char **lud_exts; size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the "real" struct so can only be used in code @@ -681,12 +686,6 @@ static bool split_str(char *str, char ***out, size_t *count) */ static bool unescape_elements (void *data, LDAPURLDesc *ludp) { - if(ludp->lud_filter) { - ludp->lud_filter = curl_easy_unescape(data, ludp->lud_filter, 0, NULL); - if(!ludp->lud_filter) - return FALSE; - } - return (TRUE); } @@ -841,13 +840,12 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) if(!p) goto success; - /* parse scope. skip "??" - */ + /* Parse the scope. skip "??" */ q = strchr(p, '?'); if(q) *q++ = '\0'; - if(*p && *p != '?') { + if(*p) { ludp->lud_scope = str2scope(p); if(ludp->lud_scope == -1) { rc = LDAP_INVALID_SYNTAX; @@ -861,20 +859,50 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp) if(!p) goto success; - /* parse filter - */ + /* Parse the filter */ q = strchr(p, '?'); if(q) *q++ = '\0'; - if(!*p) { + + if(*p) { + char *filter = p; + char *unescapped; + + LDAP_TRACE (("filter '%s'\n", filter)); + + /* Unescape the filter */ + unescapped = curl_easy_unescape(conn->data, filter, 0, NULL); + if(!unescapped) { + rc = LDAP_NO_MEMORY; + + goto quit; + } + +#if defined(CURL_LDAP_WIN) && \ + (defined(USE_WIN32_IDN) || defined(USE_WINDOWS_SSPI)) + /* Convert the unescapped string to a tchar */ + ludp->lud_filter = Curl_convert_UTF8_to_tchar(unescapped); + + /* Free the unescapped string as we are done with it */ + Curl_unicodefree(unescapped); + + if(!ludp->lud_filter) { + rc = LDAP_NO_MEMORY; + + goto quit; + } +#else + ludp->lud_filter = unescapped; +#endif + } + + p = q; + if(p && !*p) { rc = LDAP_INVALID_SYNTAX; goto quit; } - ludp->lud_filter = p; - LDAP_TRACE (("filter '%s'\n", ludp->lud_filter)); - success: if(!unescape_elements(conn->data, ludp)) rc = LDAP_NO_MEMORY; |