[Svn] r3882 - trunk/roundcubemail/program/include

trac at roundcube.net trac at roundcube.net
Sun Aug 8 13:39:19 CEST 2010


Author: alec
Date: 2010-08-08 06:39:19 -0500 (Sun, 08 Aug 2010)
New Revision: 3882

Modified:
   trunk/roundcubemail/program/include/rcube_imap_generic.php
Log:
- Small improvement in SELECT response parsing


Modified: trunk/roundcubemail/program/include/rcube_imap_generic.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_imap_generic.php	2010-08-08 10:53:57 UTC (rev 3881)
+++ trunk/roundcubemail/program/include/rcube_imap_generic.php	2010-08-08 11:39:19 UTC (rev 3882)
@@ -749,31 +749,24 @@
 
 	    if ($this->putLine("sel1 SELECT \"".$this->escape($mailbox).'"')) {
 		    do {
-			    $line = rtrim($this->readLine(300));
-			    $a = explode(' ', $line);
-			    if (count($a) == 3) {
-				    $token = strtoupper($a[2]);
-				    if ($token == 'EXISTS') {
-					    $this->exists = (int) $a[1];
-				    }
-				    else if ($token == 'RECENT') {
-					    $this->recent = (int) $a[1];
-				    }
+			    $line = rtrim($this->readLine(512));
+
+			    if (preg_match('/^\* ([0-9]+) (EXISTS|RECENT)$/', $line, $m)) {
+			        $token = strtolower($m[2]);
+			        $this->$token = (int) $m[1];
 			    }
 			    else if (preg_match('/\[?PERMANENTFLAGS\s+\(([^\)]+)\)\]/U', $line, $match)) {
 				    $this->permanentflags = explode(' ', $match[1]);
 			    }
 		    } while (!$this->startsWith($line, 'sel1', true, true));
 
-		    if (strcasecmp($a[1], 'OK') == 0) {
+            if ($this->parseResult($line) == 0) {
 			    $this->selected = $mailbox;
 			    return true;
 		    }
-            else {
-                $this->error = "Couldn't select $mailbox";
-            }
 	    }
 
+        $this->error = "Couldn't select $mailbox";
         return false;
     }
 

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



More information about the Svn mailing list