From: pdontthink Date: Sat, 23 May 2020 19:42:22 +0000 (+0000) Subject: Show better filesize approximations for base64-encoded attachments X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=24e8917ead46268f6a4264900c832b4a5c37ee84;ds=sidebyside Show better filesize approximations for base64-encoded attachments git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14862 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/mime.php b/functions/mime.php index 002e7889..56ee0d47 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -635,7 +635,13 @@ function buildAttachmentArray($message, $exclude_id, $mailbox, $id) { $this_attachment['DefaultHREF'] = $defaultlink; $this_attachment['DownloadHREF'] = $links['download link']['href']; $this_attachment['ViewHREF'] = isset($links['attachment_common']) ? $links['attachment_common']['href'] : ''; - $this_attachment['Size'] = $header->size; + + // base64 encoded file sizes are misleading, so approximate real size + if (!empty($header->encoding) && strtolower($header->encoding) == 'base64') + $this_attachment['Size'] = $header->size / 4 * 3; + else + $this_attachment['Size'] = $header->size; + $this_attachment['ContentType'] = sm_encode_html_special_chars($type0 .'/'. $type1); $this_attachment['OtherLinks'] = array(); foreach ($links as $val) {