diff options
author | Werner Koch <[email protected]> | 2019-11-26 12:09:35 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2019-11-26 12:09:35 +0000 |
commit | 264c15c72fe050f5e8d2f1cb2444a459df6fe99f (patch) | |
tree | aa2f381705526fdb8860026137174ba970a24207 /dirmngr/ldap-parse-uri.c | |
parent | dirmngr: Make building with a TLS library mandatory (diff) | |
download | gnupg-264c15c72fe050f5e8d2f1cb2444a459df6fe99f.tar.gz gnupg-264c15c72fe050f5e8d2f1cb2444a459df6fe99f.zip |
dirmngr: Rework of the LDAP code, part 1.
* dirmngr/http.h (struct parsed_uri_s): Add flag is_ldap.
* dirmngr/http.c (do_parse_uri): Set flag. Do not error out for a
missing slashes in an http scheme if NO_SCHEME_CHECK is active.
* dirmngr/t-http.c (main): Print new flag.
* dirmngr/ks-engine-ldap.c (ks_ldap_help): Use flag instead of
checking the scheme.
* dirmngr/ldap-parse-uri.c (ldap_uri_p): Re-implement using
http_parse_uri.
* dirmngr/t-ldap-parse-uri.c (main): Add option --verbose.
--
This patch merely remove the separate parser for checking for an LDAP
scheme. It is better to let our generic URI parser handle this. Also
fixes this bug
|| url[4] == 'i' || url[4] == 'i')
to make the rarely used ldapi scheme case-insensitive.
More changes to the LDAP code are planned.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'dirmngr/ldap-parse-uri.c')
-rw-r--r-- | dirmngr/ldap-parse-uri.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/dirmngr/ldap-parse-uri.c b/dirmngr/ldap-parse-uri.c index 94d4efd38..240b98def 100644 --- a/dirmngr/ldap-parse-uri.c +++ b/dirmngr/ldap-parse-uri.c @@ -30,37 +30,24 @@ #include "../common/util.h" #include "http.h" -/* Returns 1 if the string is an LDAP URL (begins with ldap:, ldaps: - or ldapi:). */ +/* Returns 1 if the string is an LDAP URL. */ int ldap_uri_p (const char *url) { - char *colon = strchr (url, ':'); - if (! colon) - return 0; + parsed_uri_t puri; + int result; + + if (http_parse_uri (&puri, url, 1)) + result = 0; else - { - int offset = (uintptr_t) colon - (uintptr_t) url; - - if (/* All lower case. */ - (offset == 4 && memcmp (url, "ldap", 4) == 0) - || (offset == 5 - && (memcmp (url, "ldaps", 5) == 0 - && memcmp (url, "ldapi", 5) == 0)) - /* Mixed case. */ - || ((url[0] == 'l' || url[0] == 'L') - && (url[1] == 'd' || url[1] == 'D') - && (url[2] == 'a' || url[2] == 'A') - && (url[3] == 'p' || url[3] == 'P') - && (url[4] == ':' - || ((url[4] == 's' || url[4] == 'S' - || url[4] == 'i' || url[4] == 'i') - && url[5] == ':')))) - return 1; - return 0; - } + result = !!puri->is_ldap; + + http_release_parsed_uri (puri); + + return result; } + /* Parse a URI and put the result into *purip. On success the caller must use http_release_parsed_uri() to releases the resources. |