diff --git a/plugins/zipdownload/composer.json b/plugins/zipdownload/composer.json index 2d772e52f..3d86619a5 100644 --- a/plugins/zipdownload/composer.json +++ b/plugins/zipdownload/composer.json @@ -3,7 +3,7 @@ "type": "roundcube-plugin", "description": "Adds an option to download all attachments to a message in one zip file, when a message has multiple attachments. Also allows the download of a selection of messages in one zip file. Supports mbox and maildir format.", "license": "GPLv3+", - "version": "3.1", + "version": "3.2", "authors": [ { "name": "Thomas Bruederli", diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index 8f7139db1..aa154b81a 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -4,10 +4,10 @@ * ZipDownload * * Plugin to allow the download of all message attachments in one zip file - * and downloading of many messages in one go. + * and also download of many messages in one go. * - * @version 3.1 * @requires php_zip extension (including ZipArchive class) + * * @author Philip Weir * @author Thomas Bruderli * @author Aleksander Machniak @@ -15,8 +15,12 @@ class zipdownload extends rcube_plugin { public $task = 'mail'; + private $charset = 'ASCII'; + // RFC4155: mbox date format + const MBOX_DATE_FORMAT = 'D M d H:i:s Y'; + /** * Plugin initialization */ @@ -225,17 +229,22 @@ class zipdownload extends rcube_plugin $headers = $imap->get_message_headers($uid); if ($mode == 'mbox') { + // Sender address $from = rcube_mime::decode_address_list($headers->from, null, true, $headers->charset, true); $from = array_shift($from); + $from = preg_replace('/\s/', '-', $from); + + // Received (internal) date + $date = rcube_utils::anytodatetime($headers->internaldate); + if ($date) { + $date->setTimezone(new DateTimeZone('UTC')); + $date = $date->format(self::MBOX_DATE_FORMAT); + } - // Mbox format header - // @FIXME: \r\n or \n - // @FIXME: date format + // Mbox format header (RFC4155) $header = sprintf("From %s %s\r\n", - // replace spaces with hyphens - $from ? preg_replace('/\s/', '-', $from) : 'MAILER-DAEMON', - // internaldate - $headers->internaldate + $from ?: 'MAILER-DAEMON', + $date ?: '' ); fwrite($tmpfp, $header);