Fix: Login mechanisms other than "login" were broken if server returned untagged...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 22 May 2022 22:30:12 +0000 (22:30 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 22 May 2022 22:30:12 +0000 (22:30 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14959 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/imap_general.php

index 64828ffc7d72356927edade9356172c27b0d8f94..3b355f9e2c2dd5226fff9cd4fd3580f843890fce 100755 (executable)
@@ -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];