From 4064452816e7e94b7a6dbc7b02cfc56d725408b2 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Wed, 08 Dec 2010 09:24:53 -0500
Subject: [PATCH] - Fix handling of untagged responses for AUTHENTICATE command (#1487450) 

---
 CHANGELOG                              |    1 +
 program/include/rcube_imap_generic.php |   11 +++++------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 70b00a7..1ce37f2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -18,6 +18,7 @@
 - Improve performance of folder rename and delete actions
 - Better support for READ-ONLY and NOPERM responses handling (#1487083)
 - Add confirmation message on purge/expunge command response
+- Fix handling of untagged responses for AUTHENTICATE command (#1487450)
 
 RELEASE 0.5-BETA
 ----------------
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index b2346ba..e721353 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -282,7 +282,6 @@
 	    return $data;
     }
 
-    // don't use it in loops, until you exactly know what you're doing
     function readReply(&$untagged=null)
     {
 	    do {
@@ -421,7 +420,7 @@
             }
 
 		    $this->putLine($this->nextTag() . " AUTHENTICATE $type");
-		    $line = trim($this->readLine(1024));
+		    $line = trim($this->readReply());
 
 		    if ($line[0] == '+') {
 			    $challenge = substr($line, 2);
@@ -471,7 +470,7 @@
 
                 // send result
                 $this->putLine($reply);
-                $line = $this->readLine(1024);
+                $line = trim($this->readReply());
 
                 if ($line[0] == '+') {
 			        $challenge = substr($line, 2);
@@ -491,7 +490,7 @@
                 $this->putLine('');
             }
 
-            $line = $this->readLine(1024);
+            $line = $this->readReply();
             $result = $this->parseResult($line);
         }
         else { // PLAIN
@@ -513,7 +512,7 @@
             }
             else {
     		    $this->putLine($this->nextTag() . " AUTHENTICATE PLAIN");
-	    	    $line = trim($this->readLine(1024));
+	    	    $line = trim($this->readReply());
 
 		        if ($line[0] != '+') {
     			    return $this->parseResult($line);
@@ -521,7 +520,7 @@
 
                 // send result, get reply and process it
                 $this->putLine($reply);
-                $line = $this->readLine(1024);
+                $line = $this->readReply();
                 $result = $this->parseResult($line);
             }
         }

--
Gitblit v1.9.1