diff options
Diffstat (limited to 'lib/smtp.c')
-rw-r--r-- | lib/smtp.c | 51 |
1 files changed, 32 insertions, 19 deletions
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; |