Aleksander Machniak
2014-10-23 81dab388d0aa982f6eecc23dcbfb9afdb17ef2e1
Fix handling of UNKNOWN-CTE response, try do decode content client-side (#1490046)
2 files modified
16 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_imap_generic.php 15 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -58,6 +58,7 @@
- Fix download of attachments that are part of TNEF message (#1490091)
- Fix handling of uuencoded messages if messages_cache is enabled (#1490108)
- Fix handling of base64-encoded attachments with extra spaces (#1490111)
- Fix handling of UNKNOWN-CTE response, try do decode content client-side (#1490046)
RELEASE 1.0.3
-------------
program/lib/Roundcube/rcube_imap_generic.php
@@ -2569,6 +2569,10 @@
            return false;
        }
        $initiated = false;
        do {
            if (!$initiated) {
        switch ($encoding) {
        case 'base64':
            $mode = 1;
@@ -2587,7 +2591,7 @@
        }
        // Use BINARY extension when possible (and safe)
        $binary     = $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY');
                $binary     = !$binary_err && $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY');
        $fetch_mode = $binary ? 'BINARY' : 'BODY';
        $partial    = $max_bytes ? sprintf('<0.%d>', $max_bytes) : '';
@@ -2596,6 +2600,7 @@
        $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part]$partial)";
        $result  = false;
        $found   = false;
                $initiated  = true;
        // send request
        if (!$this->putLine($request)) {
@@ -2607,10 +2612,16 @@
            // WARNING: Use $formatted argument with care, this may break binary data stream
            $mode = -1;
        }
            }
        do {
            $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;
            }