diff options
author | alecpl <alec@alec.pl> | 2010-08-08 10:53:57 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-08-08 10:53:57 +0000 |
commit | 7f5b535d12e63ab73f850d8ad7afd5870dc4a943 (patch) | |
tree | 357ba4b7a43aa2878f7c4c68cb1da6b5d2571dfa /program | |
parent | 7123423b3a5a035d5a27a29dc3e14490aa06b53d (diff) |
- Improved performance of LIST/LSUB response parsing
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcube_imap_generic.php | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php index fcde08c83..3a44b3b8a 100644 --- a/program/include/rcube_imap_generic.php +++ b/program/include/rcube_imap_generic.php @@ -1669,8 +1669,11 @@ class rcube_imap_generic $command = 'LIST'; } + $ref = $this->escape($ref); + $mailbox = $this->escape($mailbox); + // send command - if (!$this->putLine($key." ".$command." \"". $this->escape($ref) ."\" \"". $this->escape($mailbox) ."\"")) { + if (!$this->putLine($key." ".$command." \"". $ref ."\" \"". $mailbox ."\"")) { $this->error = "Couldn't send $command command"; return false; } @@ -1679,16 +1682,15 @@ class rcube_imap_generic do { $line = $this->readLine(500); $line = $this->multLine($line, true); - $a = explode(' ', $line); - - if (($line[0] == '*') && ($a[1] == $command)) { - $line = rtrim($line); - // split one line - $a = rcube_explode_quoted_string(' ', $line); - // last string is folder name - $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($a[count($a)-1])); - // second from last is delimiter - $delim = trim($a[count($a)-2], '"'); + $line = trim($line); + + if (preg_match('/^\* '.$command.' \(([^\)]*)\) "*([^"]+)"* (.*)$/', $line, $m)) { + // folder name + $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($m[3])); + // attributes +// $attrib = explode(' ', $m[1]); + // delimiter +// $delim = $m[2]; } } while (!$this->startsWith($line, $key, true)); |