diff options
-rw-r--r-- | lib/imap.c | 54 | ||||
-rw-r--r-- | lib/pop3.c | 56 | ||||
-rw-r--r-- | lib/smtp.c | 51 |
3 files changed, 99 insertions, 62 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; diff --git a/lib/pop3.c b/lib/pop3.c index 782458ada..8e5288d0c 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -1832,56 +1832,68 @@ static CURLcode pop3_parse_url_options(struct connectdata *conn) struct pop3_conn *pop3c = &conn->proto.pop3c; 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; + pop3c->preftype = POP3_TYPE_NONE; + pop3c->prefmech = SASL_AUTH_NONE; + } + + while(*ptr && *ptr != ';') { + ptr++; + len++; + } + + if(strnequal(value, "*", len)) { pop3c->preftype = POP3_TYPE_ANY; pop3c->prefmech = SASL_AUTH_ANY; } - else if(strequal(value, "+APOP")) { + else if(strnequal(value, "+APOP", len)) { pop3c->preftype = POP3_TYPE_APOP; pop3c->prefmech = SASL_AUTH_NONE; } - else if(strequal(value, SASL_MECH_STRING_LOGIN)) { + else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_LOGIN; + pop3c->prefmech |= SASL_MECH_LOGIN; } - else if(strequal(value, SASL_MECH_STRING_PLAIN)) { + else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_PLAIN; + pop3c->prefmech |= SASL_MECH_PLAIN; } - else if(strequal(value, SASL_MECH_STRING_CRAM_MD5)) { + else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_CRAM_MD5; + pop3c->prefmech |= SASL_MECH_CRAM_MD5; } - else if(strequal(value, SASL_MECH_STRING_DIGEST_MD5)) { + else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_DIGEST_MD5; + pop3c->prefmech |= SASL_MECH_DIGEST_MD5; } - else if(strequal(value, SASL_MECH_STRING_GSSAPI)) { + else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_GSSAPI; + pop3c->prefmech |= SASL_MECH_GSSAPI; } - else if(strequal(value, SASL_MECH_STRING_NTLM)) { + else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_NTLM; + pop3c->prefmech |= SASL_MECH_NTLM; } - else if(strequal(value, SASL_MECH_STRING_XOAUTH2)) { + else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) { pop3c->preftype = POP3_TYPE_SASL; - pop3c->prefmech = SASL_MECH_XOAUTH2; - } - else { - pop3c->preftype = POP3_TYPE_NONE; - pop3c->prefmech = SASL_AUTH_NONE; + pop3c->prefmech |= SASL_MECH_XOAUTH2; } + + if(*ptr == ';') + ptr++; } else result = CURLE_URL_MALFORMAT; diff --git a/lib/smtp.c b/lib/smtp.c index 4d7be482c..a1f1a9190 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -1927,34 +1927,47 @@ static CURLcode smtp_parse_url_options(struct connectdata *conn) struct smtp_conn *smtpc = &conn->proto.smtpc; 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, "*")) - smtpc->prefmech = SASL_AUTH_ANY; - else if(strequal(value, SASL_MECH_STRING_LOGIN)) - smtpc->prefmech = SASL_MECH_LOGIN; - else if(strequal(value, SASL_MECH_STRING_PLAIN)) - smtpc->prefmech = SASL_MECH_PLAIN; - else if(strequal(value, SASL_MECH_STRING_CRAM_MD5)) - smtpc->prefmech = SASL_MECH_CRAM_MD5; - else if(strequal(value, SASL_MECH_STRING_DIGEST_MD5)) - smtpc->prefmech = SASL_MECH_DIGEST_MD5; - else if(strequal(value, SASL_MECH_STRING_GSSAPI)) - smtpc->prefmech = SASL_MECH_GSSAPI; - else if(strequal(value, SASL_MECH_STRING_NTLM)) - smtpc->prefmech = SASL_MECH_NTLM; - else if(strequal(value, SASL_MECH_STRING_XOAUTH2)) - smtpc->prefmech = SASL_MECH_XOAUTH2; - else + if(reset) { + reset = FALSE; smtpc->prefmech = SASL_AUTH_NONE; + } + + while(*ptr && *ptr != ';') { + ptr++; + len++; + } + + if(strnequal(value, "*", len)) + smtpc->prefmech = SASL_AUTH_ANY; + else if(strnequal(value, SASL_MECH_STRING_LOGIN, len)) + smtpc->prefmech |= SASL_MECH_LOGIN; + else if(strnequal(value, SASL_MECH_STRING_PLAIN, len)) + smtpc->prefmech |= SASL_MECH_PLAIN; + else if(strnequal(value, SASL_MECH_STRING_CRAM_MD5, len)) + smtpc->prefmech |= SASL_MECH_CRAM_MD5; + else if(strnequal(value, SASL_MECH_STRING_DIGEST_MD5, len)) + smtpc->prefmech |= SASL_MECH_DIGEST_MD5; + else if(strnequal(value, SASL_MECH_STRING_GSSAPI, len)) + smtpc->prefmech |= SASL_MECH_GSSAPI; + else if(strnequal(value, SASL_MECH_STRING_NTLM, len)) + smtpc->prefmech |= SASL_MECH_NTLM; + else if(strnequal(value, SASL_MECH_STRING_XOAUTH2, len)) + smtpc->prefmech |= SASL_MECH_XOAUTH2; + + if(*ptr == ';') + ptr++; } else result = CURLE_URL_MALFORMAT; |