diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-04-29 13:32:29 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-04-29 13:33:39 +0200 |
commit | 9712d2240a12b7b63aa20d3b1c86856637b69176 (patch) | |
tree | 937a822769f0a58f4f59664b24941e61ec2f1269 | |
parent | 6c3e466c747ed43f196344e86d851297c7b87fac (diff) |
Fix handling untagged responses in IMAP FETCH - "could not load message" error (#1489074)
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | program/lib/Roundcube/rcube_imap_generic.php | 19 |
2 files changed, 15 insertions, 5 deletions
@@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Fix handling untagged responses in IMAP FETCH - "could not load message" error (#1489074) - Fix very small window size in Chrome (#1488931) - Fix list page reset when viewing a message in Larry skin (#1489076) - Fix min_refresh_interval handling on preferences save (#1489073) diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index 8182aa117..bd0a829f0 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -2447,6 +2447,7 @@ class rcube_imap_generic $key = $this->nextTag(); $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part]$partial)"; $result = false; + $found = false; // send request if (!$this->putLine($request)) { @@ -2466,18 +2467,25 @@ class rcube_imap_generic 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; } $line = $m[2]; - $last = substr($line, -1); // handle one line response - if ($line[0] == '(' && $last == ')') { + if ($line[0] == '(' && substr($line, -1) == ')') { // tokenize content inside brackets - $tokens = $this->tokenizeResponse(preg_replace('/(^\(|\$)/', '', $line)); - $result = count($tokens) == 1 ? $tokens[0] : false; + $tokens = $this->tokenizeResponse(preg_replace('/(^\(|\)$)/', '', $line)); + + 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 ($mode == 1) { @@ -2495,6 +2503,7 @@ class rcube_imap_generic else if (preg_match('/\{([0-9]+)\}$/', $line, $m)) { $bytes = (int) $m[1]; $prev = ''; + $found = true; while ($bytes > 0) { $line = $this->readLine(8192); |