|
|
|
@ -220,6 +220,36 @@ class rcube_imap_generic
|
|
|
|
|
return $line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads a line of data from the connection stream inluding all
|
|
|
|
|
* string continuation literals.
|
|
|
|
|
*
|
|
|
|
|
* @param int $size Buffer size
|
|
|
|
|
*
|
|
|
|
|
* @return string Line of text response
|
|
|
|
|
*/
|
|
|
|
|
protected function readFullLine($size = 1024)
|
|
|
|
|
{
|
|
|
|
|
$line = $this->readLine($size);
|
|
|
|
|
|
|
|
|
|
// include all string literels untile the real end of "line"
|
|
|
|
|
while (preg_match('/\{([0-9]+)\}\r\n$/', $line, $m)) {
|
|
|
|
|
$bytes = $m[1] + 2;
|
|
|
|
|
$out = '';
|
|
|
|
|
|
|
|
|
|
while (strlen($out) < $bytes) {
|
|
|
|
|
$out = $this->readBytes($bytes);
|
|
|
|
|
if ($out === null) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$line .= $out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads more data from the connection stream when provided
|
|
|
|
|
* data contain string literal
|
|
|
|
@ -2397,7 +2427,7 @@ class rcube_imap_generic
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
$line = $this->readLine(4096);
|
|
|
|
|
$line = $this->readFullLine(4096);
|
|
|
|
|
|
|
|
|
|
if (!$line) {
|
|
|
|
|
break;
|
|
|
|
@ -2421,27 +2451,6 @@ class rcube_imap_generic
|
|
|
|
|
$line = substr($line, strlen($m[0]) + 2);
|
|
|
|
|
$ln = 0;
|
|
|
|
|
|
|
|
|
|
// get complete entry
|
|
|
|
|
while (preg_match('/\{([0-9]+)\}\r\n$/', $line, $m)) {
|
|
|
|
|
$bytes = $m[1];
|
|
|
|
|
$out = '';
|
|
|
|
|
|
|
|
|
|
while (strlen($out) < $bytes) {
|
|
|
|
|
$out = $this->readBytes($bytes);
|
|
|
|
|
if ($out === null) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$line .= $out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$str = $this->readLine(4096);
|
|
|
|
|
if ($str === false) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$line .= $str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tokenize response and assign to object properties
|
|
|
|
|
while (list($name, $value) = $this->tokenizeResponse($line, 2)) {
|
|
|
|
|
if ($name == 'UID') {
|
|
|
|
@ -3721,24 +3730,9 @@ class rcube_imap_generic
|
|
|
|
|
|
|
|
|
|
// Parse response
|
|
|
|
|
do {
|
|
|
|
|
$line = $this->readLine(4096);
|
|
|
|
|
$line = $this->readFullLine(4096);
|
|
|
|
|
|
|
|
|
|
if ($response !== null) {
|
|
|
|
|
// In filter mode we need additional code for string literals.
|
|
|
|
|
// We'll merge the following literal data into one chunk, so
|
|
|
|
|
// it can be compared with the filter below
|
|
|
|
|
if ($filter && preg_match('/\{([0-9]+)\}\r\n$/', $line, $match)) {
|
|
|
|
|
// read and append the given bytes
|
|
|
|
|
$bytes = $match[1];
|
|
|
|
|
$out = '';
|
|
|
|
|
while (strlen($out) < $bytes) {
|
|
|
|
|
$tmp = $this->readBytes($bytes);
|
|
|
|
|
if ($tmp === null) break;
|
|
|
|
|
$out .= $tmp;
|
|
|
|
|
}
|
|
|
|
|
$line .= $out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$filter || preg_match($filter, $line)) {
|
|
|
|
|
$response .= $line;
|
|
|
|
|
}
|
|
|
|
|