summaryrefslogtreecommitdiff
path: root/program/include/rcube_imap_generic.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-09-17 22:04:16 +0200
committerThomas Bruederli <thomas@roundcube.net>2012-09-17 22:04:16 +0200
commit8f098e8dead85b6512ac72b2d805314baec72a2f (patch)
tree96b89dbcc2a58dab0f2dd1183beef3036c13287f /program/include/rcube_imap_generic.php
parent99d9f50a0000447d0a752e6c43716237dc0da176 (diff)
parent6898b420ed4eb2bd2d1933758cde27bdd305d72a (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'program/include/rcube_imap_generic.php')
-rw-r--r--program/include/rcube_imap_generic.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/program/include/rcube_imap_generic.php b/program/include/rcube_imap_generic.php
index 25e6fc421..cce53aedc 100644
--- a/program/include/rcube_imap_generic.php
+++ b/program/include/rcube_imap_generic.php
@@ -2402,10 +2402,13 @@ class rcube_imap_generic
$mode = 0;
}
+ // Use BINARY extension when possible (and safe)
+ $binary = $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY');
+ $fetch_mode = $binary ? 'BINARY' : 'BODY';
+
// format request
- $reply_key = '* ' . $id;
$key = $this->nextTag();
- $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id (BODY.PEEK[$part])";
+ $request = $key . ($is_uid ? ' UID' : '') . " FETCH $id ($fetch_mode.PEEK[$part])";
// send request
if (!$this->putLine($request)) {
@@ -2413,6 +2416,10 @@ class rcube_imap_generic
return false;
}
+ if ($binary) {
+ $mode = -1;
+ }
+
// receive reply line
do {
$line = rtrim($this->readLine(1024));
@@ -2457,13 +2464,13 @@ class rcube_imap_generic
$prev = '';
while ($bytes > 0) {
- $line = $this->readLine(4096);
+ $line = $this->readLine(8192);
if ($line === NULL) {
break;
}
- $len = strlen($line);
+ $len = strlen($line);
if ($len > $bytes) {
$line = substr($line, 0, $bytes);