summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-07-30 19:16:52 +0200
committerAleksander Machniak <alec@alec.pl>2013-07-30 19:16:52 +0200
commitae853367edd2720e2f899aa273ca8ac1a08f0079 (patch)
tree1b55f2770f6e880ab422b7e2a2e453cd59d25b53
parent86dd03677466ceb37e0a2d3d43e8a76472966745 (diff)
Fix downloading binary files with (wrong) text/* content-type (#1489267)
-rw-r--r--CHANGELOG1
-rw-r--r--program/lib/Roundcube/rcube_imap.php20
-rw-r--r--program/lib/Roundcube/rcube_message.php6
-rw-r--r--program/steps/mail/get.inc3
4 files changed, 18 insertions, 12 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ab5d125cc..64ccc77c8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix downloading binary files with (wrong) text/* content-type (#1489267)
- Fix rewrite rule in .htaccess (#1489240)
- Fix detecting Turkish language in ISO-8859-9 encoding (#1489252)
- Fix identity-selection using Return-Path headers (#1489241)
diff --git a/program/lib/Roundcube/rcube_imap.php b/program/lib/Roundcube/rcube_imap.php
index b60aefc5f..c5346c8aa 100644
--- a/program/lib/Roundcube/rcube_imap.php
+++ b/program/lib/Roundcube/rcube_imap.php
@@ -2092,17 +2092,18 @@ class rcube_imap extends rcube_storage
/**
* Fetch message body of a specific message from the server
*
- * @param int $uid Message UID
- * @param string $part Part number
- * @param rcube_message_part $o_part Part object created by get_structure()
- * @param mixed $print True to print part, ressource to write part contents in
- * @param resource $fp File pointer to save the message part
- * @param boolean $skip_charset_conv Disables charset conversion
- * @param int $max_bytes Only read this number of bytes
+ * @param int Message UID
+ * @param string Part number
+ * @param rcube_message_part Part object created by get_structure()
+ * @param mixed True to print part, resource to write part contents in
+ * @param resource File pointer to save the message part
+ * @param boolean Disables charset conversion
+ * @param int Only read this number of bytes
+ * @param boolean Enables formatting of text/* parts bodies
*
* @return string Message/part body if not printed
*/
- public function get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false, $max_bytes=0)
+ public function get_message_part($uid, $part=1, $o_part=NULL, $print=NULL, $fp=NULL, $skip_charset_conv=false, $max_bytes=0, $formatted=true)
{
if (!$this->check_connection()) {
return null;
@@ -2121,8 +2122,9 @@ class rcube_imap extends rcube_storage
}
if ($o_part && $o_part->size) {
+ $formatted = $formatted && $o_part->ctype_primary == 'text';
$body = $this->conn->handlePartBody($this->folder, $uid, true,
- $part ? $part : 'TEXT', $o_part->encoding, $print, $fp, $o_part->ctype_primary == 'text', $max_bytes);
+ $part ? $part : 'TEXT', $o_part->encoding, $print, $fp, $formatted, $max_bytes);
}
if ($fp || $print) {
diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php
index 797ca185e..0d33ea44d 100644
--- a/program/lib/Roundcube/rcube_message.php
+++ b/program/lib/Roundcube/rcube_message.php
@@ -168,10 +168,11 @@ class rcube_message
* @param resource $fp File pointer to save the message part
* @param boolean $skip_charset_conv Disables charset conversion
* @param int $max_bytes Only read this number of bytes
+ * @param boolean $formatted Enables formatting of text/* parts bodies
*
* @return string Part content
*/
- public function get_part_content($mime_id, $fp = null, $skip_charset_conv = false, $max_bytes = 0)
+ public function get_part_content($mime_id, $fp = null, $skip_charset_conv = false, $max_bytes = 0, $formatted = true)
{
if ($part = $this->mime_parts[$mime_id]) {
// stored in message structure (winmail/inline-uuencode)
@@ -185,7 +186,8 @@ class rcube_message
// get from IMAP
$this->storage->set_folder($this->folder);
- return $this->storage->get_message_part($this->uid, $mime_id, $part, NULL, $fp, $skip_charset_conv, $max_bytes);
+ return $this->storage->get_message_part($this->uid, $mime_id, $part,
+ NULL, $fp, $skip_charset_conv, $max_bytes, $formatted);
}
}
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 3334caa8b..e0c4e2911 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -357,7 +357,8 @@ else if (strlen($part_id)) {
header("Content-Length: $size");
}
- $sent = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
+ // 8th argument disables re-formatting of text/* parts (#1489267)
+ $sent = $RCMAIL->storage->get_message_part($MESSAGE->uid, $part->mime_id, $part, true, null, false, 0, false);
}
}