1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

imap: deal with commands case insensitively

As documented in RFC 3501 section 9:
https://tools.ietf.org/html/rfc3501#section-9

Closes #2061
This commit is contained in:
Daniel Stenberg 2017-11-09 00:26:21 +01:00
parent 6b12beb25a
commit e871ab56ed
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -275,15 +275,15 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
case IMAP_LIST: case IMAP_LIST:
if((!imap->custom && !imap_matchresp(line, len, "LIST")) || if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
(imap->custom && !imap_matchresp(line, len, imap->custom) && (imap->custom && !imap_matchresp(line, len, imap->custom) &&
(strcmp(imap->custom, "STORE") || (!strcasecompare(imap->custom, "STORE") ||
!imap_matchresp(line, len, "FETCH")) && !imap_matchresp(line, len, "FETCH")) &&
strcmp(imap->custom, "SELECT") && !strcasecompare(imap->custom, "SELECT") &&
strcmp(imap->custom, "EXAMINE") && !strcasecompare(imap->custom, "EXAMINE") &&
strcmp(imap->custom, "SEARCH") && !strcasecompare(imap->custom, "SEARCH") &&
strcmp(imap->custom, "EXPUNGE") && !strcasecompare(imap->custom, "EXPUNGE") &&
strcmp(imap->custom, "LSUB") && !strcasecompare(imap->custom, "LSUB") &&
strcmp(imap->custom, "UID") && !strcasecompare(imap->custom, "UID") &&
strcmp(imap->custom, "NOOP"))) !strcasecompare(imap->custom, "NOOP")))
return FALSE; return FALSE;
break; break;
@ -1053,7 +1053,7 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, int imapcode,
else if(imapcode == IMAP_RESP_OK) { else if(imapcode == IMAP_RESP_OK) {
/* Check if the UIDVALIDITY has been specified and matches */ /* Check if the UIDVALIDITY has been specified and matches */
if(imap->uidvalidity && imapc->mailbox_uidvalidity && if(imap->uidvalidity && imapc->mailbox_uidvalidity &&
strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)) { !strcasecompare(imap->uidvalidity, imapc->mailbox_uidvalidity)) {
failf(conn->data, "Mailbox UIDVALIDITY has changed"); failf(conn->data, "Mailbox UIDVALIDITY has changed");
result = CURLE_REMOTE_FILE_NOT_FOUND; result = CURLE_REMOTE_FILE_NOT_FOUND;
} }
@ -1526,9 +1526,9 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
/* Determine if the requested mailbox (with the same UIDVALIDITY if set) /* Determine if the requested mailbox (with the same UIDVALIDITY if set)
has already been selected on this connection */ has already been selected on this connection */
if(imap->mailbox && imapc->mailbox && if(imap->mailbox && imapc->mailbox &&
!strcmp(imap->mailbox, imapc->mailbox) && strcasecompare(imap->mailbox, imapc->mailbox) &&
(!imap->uidvalidity || !imapc->mailbox_uidvalidity || (!imap->uidvalidity || !imapc->mailbox_uidvalidity ||
!strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity))) strcasecompare(imap->uidvalidity, imapc->mailbox_uidvalidity)))
selected = TRUE; selected = TRUE;
/* Start the first command in the DO phase */ /* Start the first command in the DO phase */