- Fix handling of backslash as IMAP delimiter

release-0.6
alecpl 14 years ago
parent 8f94b1aad6
commit 393ba7186f

@ -21,6 +21,7 @@ CHANGELOG Roundcube Webmail
- Add Mail-Followup-To/Mail-Reply-To support (#1485547) - Add Mail-Followup-To/Mail-Reply-To support (#1485547)
- Fix confirmation message isn't displayed after sending mail on Chrome (#1486177) - Fix confirmation message isn't displayed after sending mail on Chrome (#1486177)
- Fix keyboard doesn't work with autocomplete list with Chrome (#1487029) - Fix keyboard doesn't work with autocomplete list with Chrome (#1487029)
- Fix handling of backslash as IMAP delimiter
RELEASE 0.4.1 RELEASE 0.4.1
------------- -------------

@ -423,23 +423,7 @@ class rcube_imap_generic
return true; return true;
} }
if (!$this->getCapability('NAMESPACE')) { if (!is_array($data = $this->_namespace())) {
return false;
}
if (!$this->putLine("ns1 NAMESPACE")) {
return false;
}
do {
$line = $this->readLine(1024);
if (preg_match('/^\* NAMESPACE/', $line)) {
$i = 0;
$line = $this->unEscape($line);
$data = $this->parseNamespace(substr($line,11), $i, 0, 0);
}
} while (!$this->startsWith($line, 'ns1', true, true));
if (!is_array($data)) {
return false; return false;
} }
@ -488,13 +472,9 @@ class rcube_imap_generic
} }
do { do {
$line = $this->readLine(500); $line = $this->readLine(1024);
if ($line[0] == '*') { if (preg_match('/^\* LIST \([^\)]*\) "*([^"]+)"* ""/', $line, $m)) {
$line = rtrim($line); $delimiter = $this->unEscape($m[1]);
$a = rcube_explode_quoted_string(' ', $this->unEscape($line));
if ($a[0] == '*') {
$delimiter = str_replace('"', '', $a[count($a)-2]);
}
} }
} while (!$this->startsWith($line, 'ghd', true, true)); } while (!$this->startsWith($line, 'ghd', true, true));
@ -504,23 +484,10 @@ class rcube_imap_generic
// if that fails, try namespace extension // if that fails, try namespace extension
// try to fetch namespace data // try to fetch namespace data
if (!$this->putLine("ns1 NAMESPACE")) { if (!is_array($data = $this->_namespace())) {
return false; return false;
} }
do {
$line = $this->readLine(1024);
if (preg_match('/^\* NAMESPACE/', $line)) {
$i = 0;
$line = $this->unEscape($line);
$data = $this->parseNamespace(substr($line,11), $i, 0, 0);
}
} while (!$this->startsWith($line, 'ns1', true, true));
if (!is_array($data)) {
return false;
}
// extract user space data (opposed to global/shared space) // extract user space data (opposed to global/shared space)
$user_space_data = $data[0]; $user_space_data = $data[0];
if (!is_array($user_space_data)) { if (!is_array($user_space_data)) {
@ -539,6 +506,31 @@ class rcube_imap_generic
return $delimiter; return $delimiter;
} }
function _namespace()
{
if (!$this->getCapability('NAMESPACE')) {
return false;
}
if (!$this->putLine("ns1 NAMESPACE")) {
return false;
}
do {
$line = $this->readLine(1024);
if (preg_match('/^\* NAMESPACE/', $line)) {
$i = 0;
$data = $this->parseNamespace(substr($line,11), $i, 0, 0);
}
} while (!$this->startsWith($line, 'ns1', true, true));
if (!is_array($data)) {
return false;
}
return $data;
}
function connect($host, $user, $password, $options=null) function connect($host, $user, $password, $options=null)
{ {
// set options // set options
@ -1657,9 +1649,9 @@ class rcube_imap_generic
// folder name // folder name
$folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($m[3])); $folders[] = preg_replace(array('/^"/', '/"$/'), '', $this->unEscape($m[3]));
// attributes // attributes
// $attrib = explode(' ', $m[1]); // $attrib = explode(' ', $this->unEscape($m[1]));
// delimiter // delimiter
// $delim = $m[2]; // $delim = $this->unEscape($m[2]);
} }
} while (!$this->startsWith($line, $key, true)); } while (!$this->startsWith($line, $key, true));
@ -2170,7 +2162,7 @@ class rcube_imap_generic
$in_quotes = false; $in_quotes = false;
$elem = 0; $elem = 0;
for ($i;$i<$len;$i++) { for ($i; $i<$len; $i++) {
$c = (string)$str[$i]; $c = (string)$str[$i];
if ($c == '(' && !$in_quotes) { if ($c == '(' && !$in_quotes) {
$i++; $i++;
@ -2181,7 +2173,7 @@ class rcube_imap_generic
} else if ($c == '\\') { } else if ($c == '\\') {
$i++; $i++;
if ($in_quotes) { if ($in_quotes) {
$data[$elem] .= $c.$str[$i]; $data[$elem] .= $str[$i];
} }
} else if ($c == '"') { } else if ($c == '"') {
$in_quotes = !$in_quotes; $in_quotes = !$in_quotes;

Loading…
Cancel
Save