[Svn] r2521 - trunk/roundcubemail/program/lib

trac at roundcube.net trac at roundcube.net
Fri May 22 12:45:01 CEST 2009


Author: alec
Date: 2009-05-22 05:45:01 -0500 (Fri, 22 May 2009)
New Revision: 2521

Modified:
   trunk/roundcubemail/program/lib/imap.inc
Log:
- handle startup response (#1484853)


Modified: trunk/roundcubemail/program/lib/imap.inc
===================================================================
--- trunk/roundcubemail/program/lib/imap.inc	2009-05-22 08:09:41 UTC (rev 2520)
+++ trunk/roundcubemail/program/lib/imap.inc	2009-05-22 10:45:01 UTC (rev 2521)
@@ -81,6 +81,7 @@
 		- added \* flag support 
 		- use PREG instead of EREG
 		- removed caching functions
+		- handling connection startup response
 
 ********************************************************/
 
@@ -229,7 +230,7 @@
 	return $res;
 }
 
-function iil_ReadLine($fp, $size) {
+function iil_ReadLine($fp, $size=1024) {
 	$line = '';
 
 	if (!$fp) {
@@ -614,9 +615,19 @@
 		return false;
 	}
 
-	$iil_error .= "Socket connection established\r\n";
-	$line       = iil_ReadLine($conn->fp, 4096);
+	stream_set_timeout($conn->fp, 10);
+	$line = stream_get_line($conn->fp, 8192, "\r\n");
 
+	// Connected to wrong port or connection error?
+	if (!preg_match('/^\* (OK|PREAUTH)/i', $line)) {
+		if ($line)
+			$iil_error = "Wrong startup greeting ($host:$ICL_PORT): $line";
+		else
+			$iil_error = "Empty startup greeting ($host:$ICL_PORT)";
+	        $iil_errornum = -2;
+	        return false;
+	}
+	
 	// RFC3501 [7.1] optional CAPABILITY response
 	if (preg_match('/\[CAPABILITY ([^]]+)\]/i', $line, $matches)) {
 		$conn->capability = explode(' ', strtoupper($matches[1]));

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list