From 5587b34cfa5d04fec8e009288cabd0ffdbf39413 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 30 Nov 2011 06:05:50 -0500
Subject: [PATCH] Enable buttons having an inner <span> for better CSS styling capabilities
---
program/include/rcube_imap_generic.php | 130 ++++++++++++++++++++++---------------------
1 files changed, 67 insertions(+), 63 deletions(-)
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index bcfaa81..a4e921f 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -2242,12 +2242,29 @@
list($code, $response) = $this->execute($subscribed ? 'LSUB' : 'LIST', $args);
if ($code == self::ERROR_OK) {
- $folders = array();
- while ($this->tokenizeResponse($response, 1) == '*') {
- $cmd = strtoupper($this->tokenizeResponse($response, 1));
+ $folders = array();
+ $last = 0;
+ $pos = 0;
+ $response .= "\r\n";
+
+ while ($pos = strpos($response, "\r\n", $pos+1)) {
+ // literal string, not real end-of-command-line
+ if ($response[$pos-1] == '}') {
+ continue;
+ }
+
+ $line = substr($response, $last, $pos - $last);
+ $last = $pos + 2;
+
+ if (!preg_match('/^\* (LIST|LSUB|STATUS) /i', $line, $m)) {
+ continue;
+ }
+ $cmd = strtoupper($m[1]);
+ $line = substr($line, strlen($m[0]));
+
// * LIST (<options>) <delimiter> <mailbox>
if ($cmd == 'LIST' || $cmd == 'LSUB') {
- list($opts, $delim, $mailbox) = $this->tokenizeResponse($response, 3);
+ list($opts, $delim, $mailbox) = $this->tokenizeResponse($line, 3);
// Add to result array
if (!$lstatus) {
@@ -2258,30 +2275,20 @@
}
// Add to options array
- if (!empty($opts)) {
- if (empty($this->data['LIST'][$mailbox]))
- $this->data['LIST'][$mailbox] = $opts;
- else
- $this->data['LIST'][$mailbox] = array_unique(array_merge(
- $this->data['LIST'][$mailbox], $opts));
- }
+ if (empty($this->data['LIST'][$mailbox]))
+ $this->data['LIST'][$mailbox] = $opts;
+ else if (!empty($opts))
+ $this->data['LIST'][$mailbox] = array_unique(array_merge(
+ $this->data['LIST'][$mailbox], $opts));
}
// * STATUS <mailbox> (<result>)
else if ($cmd == 'STATUS') {
- list($mailbox, $status) = $this->tokenizeResponse($response, 2);
+ list($mailbox, $status) = $this->tokenizeResponse($line, 2);
for ($i=0, $len=count($status); $i<$len; $i += 2) {
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 = '';
}
}
@@ -2393,8 +2400,10 @@
$len = strlen($line);
$result = false;
+ if ($a[2] != 'FETCH') {
+ }
// handle empty "* X FETCH ()" response
- if ($line[$len-1] == ')' && $line[$len-2] != '(') {
+ else if ($line[$len-1] == ')' && $line[$len-2] != '(') {
// one line response, get everything between first and last quotes
if (substr($line, -4, 3) == 'NIL') {
// NIL response
@@ -3174,47 +3183,48 @@
return false;
}
- static function getStructurePartType($structure, $part)
+ /**
+ * Returns data of a message part according to specified structure.
+ *
+ * @param array $structure Message structure (getStructure() result)
+ * @param string $part Message part identifier
+ *
+ * @return array Part data as hash array (type, encoding, charset, size)
+ */
+ static function getStructurePartData($structure, $part)
{
$part_a = self::getStructurePartArray($structure, $part);
- if (!empty($part_a)) {
- if (is_array($part_a[0]))
- return 'multipart';
- else if ($part_a[0])
- return $part_a[0];
- }
+ $data = array();
- return 'other';
- }
+ if (empty($part_a)) {
+ return $data;
+ }
- static function getStructurePartEncoding($structure, $part)
- {
- $part_a = self::getStructurePartArray($structure, $part);
- if ($part_a) {
- if (!is_array($part_a[0]))
- return $part_a[5];
- }
+ // content-type
+ if (is_array($part_a[0])) {
+ $data['type'] = 'multipart';
+ }
+ else {
+ $data['type'] = strtolower($part_a[0]);
- return '';
- }
+ // encoding
+ $data['encoding'] = strtolower($part_a[5]);
- static function getStructurePartCharset($structure, $part)
- {
- $part_a = self::getStructurePartArray($structure, $part);
- if ($part_a) {
- if (is_array($part_a[0]))
- return '';
- else {
- if (is_array($part_a[2])) {
- $name = '';
- while (list($key, $val) = each($part_a[2]))
- if (strcasecmp($val, 'charset') == 0)
- return $part_a[2][$key+1];
- }
- }
- }
+ // charset
+ if (is_array($part_a[2])) {
+ while (list($key, $val) = each($part_a[2])) {
+ if (strcasecmp($val, 'charset') == 0) {
+ $data['charset'] = $part_a[2][$key+1];
+ break;
+ }
+ }
+ }
+ }
- return '';
+ // size
+ $data['size'] = intval($part_a[6]);
+
+ return $data;
}
static function getStructurePartArray($a, $part)
@@ -3246,7 +3256,6 @@
return $a;
}
}
-
/**
* Creates next command identifier (tag)
@@ -3390,14 +3399,9 @@
// String atom, number, NIL, *, %
default:
- // empty or one character
- if ($str === '') {
+ // empty string
+ if ($str === '' || $str === null) {
break 2;
- }
- if (strlen($str) < 2) {
- $result[] = $str;
- $str = '';
- break;
}
// excluded chars: SP, CTL, ), [, ]
--
Gitblit v1.9.1