Zipdownload: Fix date format in mbox "From line"

pull/5288/merge
Aleksander Machniak 8 years ago
parent 2733258d2b
commit d45692131b

@ -3,7 +3,7 @@
"type": "roundcube-plugin", "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.", "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+", "license": "GPLv3+",
"version": "3.1", "version": "3.2",
"authors": [ "authors": [
{ {
"name": "Thomas Bruederli", "name": "Thomas Bruederli",

@ -4,10 +4,10 @@
* ZipDownload * ZipDownload
* *
* Plugin to allow the download of all message attachments in one zip file * 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) * @requires php_zip extension (including ZipArchive class)
*
* @author Philip Weir * @author Philip Weir
* @author Thomas Bruderli * @author Thomas Bruderli
* @author Aleksander Machniak * @author Aleksander Machniak
@ -15,8 +15,12 @@
class zipdownload extends rcube_plugin class zipdownload extends rcube_plugin
{ {
public $task = 'mail'; public $task = 'mail';
private $charset = 'ASCII'; private $charset = 'ASCII';
// RFC4155: mbox date format
const MBOX_DATE_FORMAT = 'D M d H:i:s Y';
/** /**
* Plugin initialization * Plugin initialization
*/ */
@ -225,17 +229,22 @@ class zipdownload extends rcube_plugin
$headers = $imap->get_message_headers($uid); $headers = $imap->get_message_headers($uid);
if ($mode == 'mbox') { if ($mode == 'mbox') {
// Sender address
$from = rcube_mime::decode_address_list($headers->from, null, true, $headers->charset, true); $from = rcube_mime::decode_address_list($headers->from, null, true, $headers->charset, true);
$from = array_shift($from); $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 // Mbox format header (RFC4155)
// @FIXME: \r\n or \n
// @FIXME: date format
$header = sprintf("From %s %s\r\n", $header = sprintf("From %s %s\r\n",
// replace spaces with hyphens $from ?: 'MAILER-DAEMON',
$from ? preg_replace('/\s/', '-', $from) : 'MAILER-DAEMON', $date ?: ''
// internaldate
$headers->internaldate
); );
fwrite($tmpfp, $header); fwrite($tmpfp, $header);

Loading…
Cancel
Save