Skip to content

Commit

Permalink
[mms] Workaround broken IMAP servers that don't support the required …
Browse files Browse the repository at this point in the history
…AUTH=PLAIN authentication method (Bug #12817).
  • Loading branch information
slusarz committed Nov 3, 2013
1 parent 6b4f6bb commit a56be44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
Expand Up @@ -418,6 +418,7 @@ protected function _login()
* a secure connections is not available. */
if (($secure === true) && !$this->isSecureConnection()) {
$this->setParam('secure', false);
$secure = false;
}

if ($first_login) {
Expand All @@ -434,11 +435,18 @@ protected function _login()
}
unset($auth['XOAUTH2']);

// 'PLAIN' authentication always exists if under TLS. Use it over
// all over authentication methods.
if ($this->isSecureConnection()) {
$auth_mech[] = 'PLAIN';
unset($auth['PLAIN']);
/* 'PLAIN' authentication always exists if under TLS (RFC
* 3501 [7.2.1]; RFC 2595). Use it over all other authentication
* methods, although we need to do sanity checking since broken
* IMAP servers may not support as required - fallback to
* LOGIN instead. */
if ($secure) {
if (isset($auth['PLAIN'])) {
$auth_mech[] = 'PLAIN';
unset($auth['PLAIN']);
} else {
$auth_mech[] = 'LOGIN';
}
}

// Prefer CRAM-MD5 over DIGEST-MD5, as the latter has been
Expand All @@ -452,7 +460,7 @@ protected function _login()

// Fall back to 'LOGIN' if available.
$auth_mech = array_merge($auth_mech, array_keys($auth));
if (!$this->queryCapability('LOGINDISABLED')) {
if (!$secure && !$this->queryCapability('LOGINDISABLED')) {
$auth_mech[] = 'LOGIN';
}

Expand Down
4 changes: 2 additions & 2 deletions framework/Imap_Client/package.xml
Expand Up @@ -21,7 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Workaround broken IMAP servers that don&apos;t support the required AUTH=PLAIN authentication method (Bug #12817).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -2070,7 +2070,7 @@
<date>2013-10-30</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Workaround broken IMAP servers that don&apos;t support the required AUTH=PLAIN authentication method (Bug #12817).
</notes>
</release>
</changelog>
Expand Down

0 comments on commit a56be44

Please sign in to comment.