From 8749e94b4bed36500e4f45c65cc16cfd5633ef34 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 8 Jun 2012 11:14:53 +0200 Subject: 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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'program/include') diff --git a/program/include/rcmail.php b/program/include/rcmail.php index a10a2aa72..8ec8cfe47 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -1997,6 +1997,31 @@ class rcmail extends rcube } + /** + * 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) ********* ***********************************************************************/ -- cgit v1.2.3