summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube/rcube_imap_generic.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-12-09 17:38:07 +0100
committerThomas Bruederli <thomas@roundcube.net>2012-12-09 17:38:07 +0100
commit9cd1b120d0439ca9f9ddcc5153800960f13b82f9 (patch)
tree4d5a9ea2d5615030a1ade23107e79de20d4a7f0e /program/lib/Roundcube/rcube_imap_generic.php
parent6488992dd0dcd68e487e1ca42dae62a152a0bef5 (diff)
parent4f1c887eaaadcc2b6ab2c6578481991698ea74a3 (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'program/lib/Roundcube/rcube_imap_generic.php')
-rw-r--r--program/lib/Roundcube/rcube_imap_generic.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php
index 0f32d83d1..28d56c16f 100644
--- a/program/lib/Roundcube/rcube_imap_generic.php
+++ b/program/lib/Roundcube/rcube_imap_generic.php
@@ -2548,10 +2548,11 @@ class rcube_imap_generic
* @param string $message Message content
* @param array $flags Message flags
* @param string $date Message internal date
+ * @param bool $binary Enable BINARY append (RFC3516)
*
* @return string|bool On success APPENDUID response (if available) or True, False on failure
*/
- function append($mailbox, &$message, $flags = array(), $date = null)
+ function append($mailbox, &$message, $flags = array(), $date = null, $binary = false)
{
unset($this->data['APPENDUID']);
@@ -2559,8 +2560,13 @@ class rcube_imap_generic
return false;
}
- $message = str_replace("\r", '', $message);
- $message = str_replace("\n", "\r\n", $message);
+ $binary = $binary && $this->getCapability('BINARY');
+ $literal_plus = !$binary && $this->prefs['literal+'];
+
+ if (!$binary) {
+ $message = str_replace("\r", '', $message);
+ $message = str_replace("\n", "\r\n", $message);
+ }
$len = strlen($message);
if (!$len) {
@@ -2573,12 +2579,12 @@ class rcube_imap_generic
if (!empty($date)) {
$request .= ' ' . $this->escape($date);
}
- $request .= ' {' . $len . ($this->prefs['literal+'] ? '+' : '') . '}';
+ $request .= ' ' . ($binary ? '~' : '') . '{' . $len . ($literal_plus ? '+' : '') . '}';
// send APPEND command
if ($this->putLine($request)) {
// Do not wait when LITERAL+ is supported
- if (!$this->prefs['literal+']) {
+ if (!$literal_plus) {
$line = $this->readReply();
if ($line[0] != '+') {
@@ -2620,10 +2626,11 @@ class rcube_imap_generic
* @param string $headers Message headers
* @param array $flags Message flags
* @param string $date Message internal date
+ * @param bool $binary Enable BINARY append (RFC3516)
*
* @return string|bool On success APPENDUID response (if available) or True, False on failure
*/
- function appendFromFile($mailbox, $path, $headers=null, $flags = array(), $date = null)
+ function appendFromFile($mailbox, $path, $headers=null, $flags = array(), $date = null, $binary = false)
{
unset($this->data['APPENDUID']);
@@ -2654,18 +2661,21 @@ class rcube_imap_generic
$len += strlen($headers) + strlen($body_separator);
}
+ $binary = $binary && $this->getCapability('BINARY');
+ $literal_plus = !$binary && $this->prefs['literal+'];
+
// build APPEND command
$key = $this->nextTag();
$request = "$key APPEND " . $this->escape($mailbox) . ' (' . $this->flagsToStr($flags) . ')';
if (!empty($date)) {
$request .= ' ' . $this->escape($date);
}
- $request .= ' {' . $len . ($this->prefs['literal+'] ? '+' : '') . '}';
+ $request .= ' ' . ($binary ? '~' : '') . '{' . $len . ($literal_plus ? '+' : '') . '}';
// send APPEND command
if ($this->putLine($request)) {
// Don't wait when LITERAL+ is supported
- if (!$this->prefs['literal+']) {
+ if (!$literal_plus) {
$line = $this->readReply();
if ($line[0] != '+') {