summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-06-08 11:14:53 +0200
committerAleksander Machniak <alec@alec.pl>2012-06-08 11:14:53 +0200
commit8749e94b4bed36500e4f45c65cc16cfd5633ef34 (patch)
tree07665dc44631255e06ea28b198b5bb224a25c39c /program
parent54be5ccb50be664ca4cc30fab6fb84e7be8e223e (diff)
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
Diffstat (limited to 'program')
-rw-r--r--program/include/rcmail.php25
-rw-r--r--program/steps/mail/func.inc10
-rw-r--r--program/steps/mail/show.inc5
3 files changed, 32 insertions, 8 deletions
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) *********
***********************************************************************/
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 7417c6ba3..5a18ded6b 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1477,13 +1477,13 @@ function rcmail_draftinfo_decode($str)
function rcmail_message_part_controls($attrib)
{
- global $MESSAGE;
+ global $MESSAGE, $RCMAIL;
$part = asciiwords(get_input_value('_part', RCUBE_INPUT_GPC));
if (!is_object($MESSAGE) || !is_array($MESSAGE->parts) || !($_GET['_uid'] && $_GET['_part']) || !$MESSAGE->mime_parts[$part])
return '';
- $part = $MESSAGE->mime_parts[$part];
+ $part = $MESSAGE->mime_parts[$part];
$table = new html_table(array('cols' => 3));
$filename = $part->filename;
@@ -1497,10 +1497,8 @@ function rcmail_message_part_controls($attrib)
$table->add('download-link', html::a(array('href' => './?'.str_replace('_frame=', '_download=', $_SERVER['QUERY_STRING'])), Q(rcube_label('download'))));
}
- if (!empty($part->size)) {
- $table->add('title', Q(rcube_label('filesize')));
- $table->add('header', Q(show_bytes($part->size)));
- }
+ $table->add('title', Q(rcube_label('filesize')));
+ $table->add('header', Q($RCMAIL->message_part_size($part)));
return $table->show($attrib);
}
diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc
index 158ba31c8..5fa72d77f 100644
--- a/program/steps/mail/show.inc
+++ b/program/steps/mail/show.inc
@@ -144,7 +144,7 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
function rcmail_message_attachments($attrib)
{
- global $PRINT_MODE, $MESSAGE;
+ global $PRINT_MODE, $MESSAGE, $RCMAIL;
$out = $ol = '';
@@ -156,7 +156,8 @@ function rcmail_message_attachments($attrib)
}
if ($PRINT_MODE) {
- $ol .= html::tag('li', null, sprintf("%s (%s)", Q($filename), Q(show_bytes($attach_prop->size))));
+ $size = $RCMAIL->message_part_size($attach_prop);
+ $ol .= html::tag('li', null, Q(sprintf("%s (%s)", $filename, $size)));
}
else {
if (mb_strlen($filename) > 50) {