From fbe54043cf598b19a753dc2b21a7ed558d23fd15 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 18 Aug 2011 13:40:07 -0400
Subject: [PATCH] Fix folders drop-down list: descend into root folder (e.g. INBOX) even if part of the exception list

---
 program/include/rcube_imap_generic.php |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 59e314c..e3c987c 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -1537,7 +1537,7 @@
         if ($bodystr)
             $request .= "BODYSTRUCTURE ";
         $request .= "BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT CONTENT-TYPE ";
-        $request .= "LIST-POST DISPOSITION-NOTIFICATION-TO".$add.")])";
+        $request .= "CC REPLY-TO LIST-POST DISPOSITION-NOTIFICATION-TO".$add.")])";
 
         if (!$this->putLine($request)) {
             $this->setError(self::ERROR_COMMAND, "Unable to send command: $request");
@@ -2180,7 +2180,7 @@
             while ($this->tokenizeResponse($response, 1) == '*') {
                 $cmd = strtoupper($this->tokenizeResponse($response, 1));
                 // * LIST (<options>) <delimiter> <mailbox>
-                if (!$lstatus || $cmd == 'LIST' || $cmd == 'LSUB') {
+                if ($cmd == 'LIST' || $cmd == 'LSUB') {
                     list($opts, $delim, $mailbox) = $this->tokenizeResponse($response, 3);
 
                     // Add to result array
@@ -2208,6 +2208,14 @@
                         list($name, $value) = $this->tokenizeResponse($status, 2);
                         $folders[$mailbox][$name] = $value;
                     }
+                }
+                // other untagged response line, skip it
+                else {
+                    $response = ltrim($response);
+                    if (($position = strpos($response, "\n")) !== false)
+                        $response = substr($response, $position+1);
+                    else
+                        $response = '';
                 }
             }
 
@@ -3229,8 +3237,8 @@
                     break;
                 }
 
-                // excluded chars: SP, CTL, (, ), {, ", ], %
-                if (preg_match('/^([\x21\x23\x24\x26\x27\x2A-\x5C\x5E-\x7A\x7C-\x7E]+)/', $str, $m)) {
+                // excluded chars: SP, CTL, )
+                if (preg_match('/^([^\x00-\x20\x29\x7F]+)/', $str, $m)) {
                     $result[] = $m[1] == 'NIL' ? NULL : $m[1];
                     $str = substr($str, strlen($m[1]));
                 }

--
Gitblit v1.9.1