From 8749e94b4bed36500e4f45c65cc16cfd5633ef34 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Fri, 08 Jun 2012 05:14:53 -0400 Subject: [PATCH] Fix attachment sizes in message print page and attachment preview page (#1488515) - Use size parameter from Content-Disposition header if specified, - Calculate size of base64 encoded message parts --- program/include/rcmail.php | 37 ++++++++++++++++++++++++++++++++++--- 1 files changed, 34 insertions(+), 3 deletions(-) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 20a0ff4..8ec8cfe 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -546,15 +546,16 @@ if (is_array($default_host)) { $post_host = rcube_utils::get_input_value('_host', rcube_utils::INPUT_POST); + $post_user = rcube_utils::get_input_value('_user', rcube_utils::INPUT_POST); + + list($user, $domain) = explode('@', $post_user); // direct match in default_host array if ($default_host[$post_host] || in_array($post_host, array_values($default_host))) { $host = $post_host; } - // try to select host by mail domain - list($user, $domain) = explode('@', rcube_utils::get_input_value('_user', rcube_utils::INPUT_POST)); - if (!empty($domain)) { + else if (!empty($domain)) { foreach ($default_host as $storage_host => $mail_domains) { if (is_array($mail_domains) && in_array_nocase($domain, $mail_domains)) { $host = $storage_host; @@ -1996,6 +1997,31 @@ } + /** + * Returns real size (calculated) of the message part + * + * @param rcube_message_part Message part + * + * @return string Part size (and unit) + */ + public function message_part_size($part) + { + if (isset($part->d_parameters['size'])) { + $size = $this->show_bytes((int)$part->d_parameters['size']); + } + else { + $size = $part->size; + if ($part->encoding == 'base64') { + $size = $size / 1.33; + } + + $size = '~' . $this->show_bytes($size); + } + + return $size; + } + + /************************************************************************ ********* Deprecated methods (to be removed) ********* ***********************************************************************/ @@ -2010,6 +2036,11 @@ return $this->storage_connect(); } + public function imap_init() + { + return $this->storage_init(); + } + /** * Connect to the mail storage server with stored session data * -- Gitblit v1.9.1