From 25f779d2e90627f989da32dbd3cf7a0e3e3d2a3b Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 06 Mar 2009 02:31:30 -0500
Subject: [PATCH] - Fix errors handling in IMAP command continuations (#1485762)

---
 CHANGELOG            |    4 ++++
 program/lib/imap.inc |    9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 330776e..431ae06 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,10 @@
 CHANGELOG RoundCube Webmail
 ---------------------------
 
+2009/03/06 (alec)
+----------
+- Fix errors handling in IMAP command continuations (#1485762)
+
 2009/03/04 (alec)
 ----------
 - Fix datetime columns defaults in mysql's DDL (#1485641)
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index 0566322..f50abea 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -220,6 +220,9 @@
 			if(preg_match('/^\{[0-9]+\}\r\n$/', $parts[$i+1])) {
 				$res += iil_PutLine($fp, $parts[$i].$parts[$i+1], false);
 				$line = iil_ReadLine($fp, 1000);
+				// handle error in command
+				if ($line[0] != '+')
+					return false;
 				$i++;
 			}
 			else
@@ -292,7 +295,7 @@
 }
 
 function iil_ParseResult($string) {
-	$a=explode(' ', $string);
+	$a = explode(' ', $string);
 	if (count($a) > 2) {
 		if (strcasecmp($a[1], 'OK') == 0) {
 			return 0;
@@ -2142,7 +2145,9 @@
 		$c = 0;
 		
 		$query = 'srch1 SEARCH ' . chop($criteria);
-		iil_PutLineC($fp, $query);
+		if (!iil_PutLineC($fp, $query)) {
+			return false;
+		}
 		do {
 			$line=trim(iil_ReadLine($fp, 10000));
 			if (eregi("^\* SEARCH", $line)) {

--
Gitblit v1.9.1