aboutsummaryrefslogtreecommitdiff
path: root/lib/imap.c
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-12-21 23:34:45 +0000
committerSteve Holme <steve_holme@hotmail.com>2013-12-21 23:49:37 +0000
commit195b63f99c2fe3df4c4f73216c01fb2332e9b107 (patch)
tree7c88cd8284ad0a0703deca550784626d8b2db061 /lib/imap.c
parent1deac31eba752536769e6eb48cee514d9ec85819 (diff)
email: Extended the login options to support multiple auth mechanisms
Diffstat (limited to 'lib/imap.c')
-rw-r--r--lib/imap.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 461494913..3656d006f 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -2312,52 +2312,64 @@ static CURLcode imap_parse_url_options(struct connectdata *conn)
struct imap_conn *imapc = &conn->proto.imapc;
const char *options = conn->options;
const char *ptr = options;
+ bool reset = TRUE;
- if(options) {
+ while(*ptr) {
const char *key = ptr;
while(*ptr && *ptr != '=')
ptr++;
if(strnequal(key, "AUTH", 4)) {
- const char *value = ptr + 1;
+ size_t len = 0;
+ const char *value = ++ptr;
- if(strequal(value, "*")) {
+ if(reset) {
+ reset = FALSE;
+ imapc->preftype = IMAP_TYPE_NONE;
+ imapc->prefmech = SASL_AUTH_NONE;
+ }
+
+ while(*ptr && *ptr != ';') {
+ ptr++;
+ len++;
+ }
+
+ if(strnequal(value, "*", len)) {
imapc->preftype = IMAP_TYPE_ANY;
imapc->prefmech = SASL_AUTH_ANY;
}
- else if(strequal(value, SASL_MECH_STRING_LOGIN)) {
+ else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_LOGIN;
+ imapc->prefmech |= SASL_MECH_LOGIN;
}
- else if(strequal(value, SASL_MECH_STRING_PLAIN)) {
+ else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_PLAIN;
+ imapc->prefmech |= SASL_MECH_PLAIN;
}
- else if(strequal(value, SASL_MECH_STRING_CRAM_MD5)) {
+ else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_CRAM_MD5;
+ imapc->prefmech |= SASL_MECH_CRAM_MD5;
}
- else if(strequal(value, SASL_MECH_STRING_DIGEST_MD5)) {
+ else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_DIGEST_MD5;
+ imapc->prefmech |= SASL_MECH_DIGEST_MD5;
}
- else if(strequal(value, SASL_MECH_STRING_GSSAPI)) {
+ else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_GSSAPI;
+ imapc->prefmech |= SASL_MECH_GSSAPI;
}
- else if(strequal(value, SASL_MECH_STRING_NTLM)) {
+ else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_NTLM;
+ imapc->prefmech |= SASL_MECH_NTLM;
}
- else if(strequal(value, SASL_MECH_STRING_XOAUTH2)) {
+ else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) {
imapc->preftype = IMAP_TYPE_SASL;
- imapc->prefmech = SASL_MECH_XOAUTH2;
- }
- else {
- imapc->preftype = IMAP_TYPE_NONE;
- imapc->prefmech = SASL_AUTH_NONE;
+ imapc->prefmech |= SASL_MECH_XOAUTH2;
}
+
+ if(*ptr == ';')
+ ptr++;
}
else
result = CURLE_URL_MALFORMAT;