|
|
@ -2475,6 +2475,7 @@ class rcube_imap_generic
|
|
|
|
$key = $this->nextTag();
|
|
|
|
$key = $this->nextTag();
|
|
|
|
$request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part]$partial)";
|
|
|
|
$request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part]$partial)";
|
|
|
|
$result = false;
|
|
|
|
$result = false;
|
|
|
|
|
|
|
|
$found = false;
|
|
|
|
|
|
|
|
|
|
|
|
// send request
|
|
|
|
// send request
|
|
|
|
if (!$this->putLine($request)) {
|
|
|
|
if (!$this->putLine($request)) {
|
|
|
@ -2494,18 +2495,25 @@ class rcube_imap_generic
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!preg_match('/^\* ([0-9]+) FETCH (.*)$/', $line, $m)) {
|
|
|
|
// skip irrelevant untagged responses (we have a result already)
|
|
|
|
|
|
|
|
if ($found || !preg_match('/^\* ([0-9]+) FETCH (.*)$/', $line, $m)) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$line = $m[2];
|
|
|
|
$line = $m[2];
|
|
|
|
$last = substr($line, -1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handle one line response
|
|
|
|
// handle one line response
|
|
|
|
if ($line[0] == '(' && $last == ')') {
|
|
|
|
if ($line[0] == '(' && substr($line, -1) == ')') {
|
|
|
|
// tokenize content inside brackets
|
|
|
|
// tokenize content inside brackets
|
|
|
|
$tokens = $this->tokenizeResponse(preg_replace('/(^\(|\$)/', '', $line));
|
|
|
|
$tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line));
|
|
|
|
$result = count($tokens) == 1 ? $tokens[0] : false;
|
|
|
|
|
|
|
|
|
|
|
|
for ($i=0; $i<count($tokens); $i+=2) {
|
|
|
|
|
|
|
|
if (preg_match('/^(BODY|BINARY)/i', $token)) {
|
|
|
|
|
|
|
|
$result = $tokens[$i+1];
|
|
|
|
|
|
|
|
$found = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($result !== false) {
|
|
|
|
if ($result !== false) {
|
|
|
|
if ($mode == 1) {
|
|
|
|
if ($mode == 1) {
|
|
|
@ -2523,6 +2531,7 @@ class rcube_imap_generic
|
|
|
|
else if (preg_match('/\{([0-9]+)\}$/', $line, $m)) {
|
|
|
|
else if (preg_match('/\{([0-9]+)\}$/', $line, $m)) {
|
|
|
|
$bytes = (int) $m[1];
|
|
|
|
$bytes = (int) $m[1];
|
|
|
|
$prev = '';
|
|
|
|
$prev = '';
|
|
|
|
|
|
|
|
$found = true;
|
|
|
|
|
|
|
|
|
|
|
|
while ($bytes > 0) {
|
|
|
|
while ($bytes > 0) {
|
|
|
|
$line = $this->readLine(8192);
|
|
|
|
$line = $this->readLine(8192);
|
|
|
|