From d903fb4dd437423f32054abd5b2164b261776555 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 09 Nov 2010 08:49:31 -0500
Subject: [PATCH] - Fix lack of IMAP server response in logged error message when using AUTHENTICATE PLAIN with SASL-IR

---
 program/include/rcube_imap_generic.php |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 6de27e8..56f30aa 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -118,6 +118,7 @@
 
     const COMMAND_NORESPONSE = 1;
     const COMMAND_CAPABILITY = 2;
+    const COMMAND_LASTLINE   = 4;
 
     /**
      * Object constructor
@@ -491,8 +492,8 @@
 
             // RFC 4959 (SASL-IR): save one round trip
             if ($this->getCapability('SASL-IR')) {
-                $result = $this->execute("AUTHENTICATE PLAIN", array($reply),
-                    self::COMMAND_NORESPONSE | self::COMMAND_CAPABILITY);
+                list($result, $line) = $this->execute("AUTHENTICATE PLAIN", array($reply),
+                    self::COMMAND_LASTLINE | self::COMMAND_CAPABILITY);
             }
             else {
     		    $this->putLine($this->nextTag() . " AUTHENTICATE PLAIN");
@@ -2888,6 +2889,11 @@
 		    $this->parseCapability($matches[1], true);
 	    }
 
+        // return last line only (without command tag and result)
+        if ($line && ($options & self::COMMAND_LASTLINE)) {
+            $response = preg_replace("/^$tag (OK|NO|BAD|BYE|PREAUTH)?\s*/i", '', trim($line));
+        }
+
 	    return $noresp ? $code : array($code, $response);
     }
 

--
Gitblit v1.9.1