diff options
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | program/lib/imap.inc | 42 |
2 files changed, 29 insertions, 16 deletions
@@ -1,6 +1,9 @@ CHANGELOG RoundCube Webmail --------------------------- +2008/05/09 (alec) +- Don't call CAPABILITY twice if possible (RFC3501 [7.1]) + 2008/05/08 (alec) ---------- - Don't attempt to delete cache entries if enable_caching is FALSE (#1485051) diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 918e71a18..0d7bc6cd3 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -51,6 +51,9 @@ - Abort do-loop on socket errors (fgets returns false) - $ICL_SSL is not boolean anymore but contains the connection schema (ssl or tls) - Removed some debuggers (echo ...) + File altered by Aleksander Machniak <alec@alec.pl> + - RFC3501 [7.1] don't call CAPABILITY twice if possible in iil_Connect() + ********************************************************/ @@ -473,36 +476,43 @@ function iil_Connect($host, $user, $password) { } $iil_error .= "Socket connection established\r\n"; - $line = iil_ReadLine($conn->fp, 300); + $line = iil_ReadLine($conn->fp, 1024); - if (strcasecmp($auth_method, "check") == 0) { - //check for supported auth methods - - //default to plain text auth - $auth_method = 'plain'; - - //check for CRAM-MD5 + // RFC3501 [7.1] optional CAPABILITY response + if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) { + $conn->capability = explode(' ', $matches[1]); + } else { fputs($conn->fp, "cp01 CAPABILITY\r\n"); do { - $line = trim(chop(iil_ReadLine($conn->fp, 100))); + $line = trim(chop(iil_ReadLine($conn->fp, 100))); - $conn->message .= "$line\n"; + $conn->message .= "$line\n"; $a = explode(' ', $line); if ($line[0] == '*') { while (list($k, $w) = each($a)) { - if ($w != '*' && $w != 'CAPABILITY') { + if ($w != '*' && $w != 'CAPABILITY') $conn->capability[] = $w; - } - if ((strcasecmp($w, "AUTH=CRAM_MD5") == 0)|| - (strcasecmp($w, "AUTH=CRAM-MD5") == 0)) { - $auth_method = "auth"; - } } } } while ($a[0] != 'cp01'); } + if (strcasecmp($auth_method, "check") == 0) { + //check for supported auth methods + + //default to plain text auth + $auth_method = 'plain'; + + //check for CRAM-MD5 + foreach ($conn->capability as $c) + if (strcasecmp($c, 'AUTH=CRAM_MD5') == 0 || + strcasecmp($c, 'AUTH=CRAM-MD5') == 0) { + $auth_method = 'auth'; + break; + } + } + if (strcasecmp($auth_method, 'auth') == 0) { $conn->message .= "Trying CRAM-MD5\n"; |