From 04179ebb44c509f1f11480bb7499e0c2f78386b0 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 22 May 2022 22:30:12 +0000 Subject: [PATCH] Fix: Login mechanisms other than "login" were broken if server returned untagged data before login response (#2854) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14959 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_general.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/functions/imap_general.php b/functions/imap_general.php index 64828ffc..3b355f9e 100755 --- a/functions/imap_general.php +++ b/functions/imap_general.php @@ -908,6 +908,11 @@ function sqimap_login ($username, $password, $imap_server_address, $read=sqimap_fgets($imap_stream); } } + // IMAP server might return some untagged info before + // the tagged login command response - skip over that + while ($read[0] === '*') { + $read = sqimap_fgets($imap_stream); + } $results=explode(" ",$read,3); $response=$results[1]; $message=$results[2]; @@ -936,7 +941,7 @@ function sqimap_login ($username, $password, $imap_server_address, * credentials and use that as the authorization identity. */ $tag=sqimap_session_id(false); - $sasl = (isset($sqimap_capabilities['SASL-IR']) && $sqimap_capabilities['SASL-IR']) ? true : false; + $sasl = sqimap_capability($imap_stream, 'SASL-IR'); if(!empty($authz)) { $auth = base64_encode("$username\0$authz\0$password"); } else { @@ -957,6 +962,11 @@ function sqimap_login ($username, $password, $imap_server_address, $read = sqimap_fgets($imap_stream); } } + // IMAP server might return some untagged info before + // the tagged login command response - skip over that + while ($read[0] === '*') { + $read = sqimap_fgets($imap_stream); + } $results=explode(" ",$read,3); $response=$results[1]; $message=$results[2]; -- 2.25.1