summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2014-10-23 18:53:50 +0200
committerAleksander Machniak <alec@alec.pl>2014-10-23 18:53:50 +0200
commita23c233db6d34aa8fab96d5d9d708a373bf4fa0f (patch)
treec3826ff13380cf0afbe76af25262c5118e4fe0bf /program
parentcbac33113a2d706b752675c83e31d8afcfb9be32 (diff)
Really fix UNKNOWN-CTE handling
Diffstat (limited to 'program')
-rw-r--r--program/lib/Roundcube/rcube_imap_generic.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 298d44cb0..d032f420d 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -2531,6 +2531,7 @@ class rcube_imap_generic
}
$initiated = false;
+ $binary = true;
do {
if (!$initiated) {
@@ -2552,16 +2553,16 @@ class rcube_imap_generic
}
// Use BINARY extension when possible (and safe)
- $binary = !$binary_err && $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY');
+ $binary = $binary && $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY');
$fetch_mode = $binary ? 'BINARY' : 'BODY';
$partial = $max_bytes ? sprintf('<0.%d>', $max_bytes) : '';
// format request
- $key = $this->nextTag();
- $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part]$partial)";
- $result = false;
- $found = false;
- $initiated = true;
+ $key = $this->nextTag();
+ $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part]$partial)";
+ $result = false;
+ $found = false;
+ $initiated = true;
// send request
if (!$this->putLine($request)) {
@@ -2577,16 +2578,16 @@ class rcube_imap_generic
$line = trim($this->readLine(1024));
- // handle UNKNOWN-CTE response - RFC 3516, try standard BODY request instead of BINARY
- if ($binary && preg_match('/^' . $key . ' NO \[UNKNOWN-CTE\]/i', $line)) {
- $initiated = false;
- continue;
- }
-
if (!$line) {
break;
}
+ // handle UNKNOWN-CTE response - RFC 3516, try again with standard BODY request
+ if ($binary && !$found && preg_match('/^' . $key . ' NO \[UNKNOWN-CTE\]/i', $line)) {
+ $binary = $initiated = false;
+ continue;
+ }
+
// skip irrelevant untagged responses (we have a result already)
if ($found || !preg_match('/^\* ([0-9]+) FETCH (.*)$/', $line, $m)) {
continue;