From 9af8e22b8ea3bd4fe9e05860058d7fce29019455 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 8 Mar 2015 10:51:19 +0100 Subject: Plugin API: added message_part_body hook, fixes around message structure handling by plugins --- program/lib/Roundcube/rcube_message.php | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'program/lib/Roundcube/rcube_message.php') diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 8af334446..b135ae0ff 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -53,13 +53,13 @@ class rcube_message public $uid; public $folder; public $headers; - public $parts = array(); - public $mime_parts = array(); + public $sender; + public $parts = array(); + public $mime_parts = array(); public $inline_parts = array(); - public $attachments = array(); - public $subject = ''; - public $sender = null; - public $is_safe = false; + public $attachments = array(); + public $subject = ''; + public $is_safe = false; const BODY_MAX_SIZE = 1048576; // 1MB @@ -217,6 +217,10 @@ class rcube_message return; } + // allow plugins to modify part body + $plugin = $this->app->plugins->exec_hook('message_part_body', + array('object' => $this, 'part' => $part)); + // only text parts can be formatted $formatted = $formatted && $part->ctype_primary == 'text'; @@ -499,8 +503,9 @@ class rcube_message $structure->headers = rcube_mime::parse_headers($headers); } } - else + else { $mimetype = $structure->mimetype; + } // show message headers if ($recursive && is_array($structure->headers) && @@ -516,11 +521,15 @@ class rcube_message array('object' => $this, 'structure' => $structure, 'mimetype' => $mimetype, 'recursive' => $recursive)); - if ($plugin['abort']) + if ($plugin['abort']) { return; + } $structure = $plugin['structure']; - list($message_ctype_primary, $message_ctype_secondary) = explode('/', $plugin['mimetype']); + $mimetype = $plugin['mimetype']; + $recursive = $plugin['recursive']; + + list($message_ctype_primary, $message_ctype_secondary) = explode('/', $mimetype); // print body if message doesn't have multiple parts if ($message_ctype_primary == 'text' && !$recursive) { @@ -673,7 +682,7 @@ class rcube_message } else { $part_mimetype = $part_orig_mimetype = $mail_part->mimetype; - } + } // multipart/alternative if ($primary_type == 'multipart') { -- cgit v1.2.3 From 98e4614b0da073b04ba54bfee1df3491dcea6762 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 6 Apr 2015 13:10:06 +0200 Subject: Fix so text/calendar parts are listed as attachments even if not marked as such (#1490325) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_message.php | 8 ++++++++ 2 files changed, 9 insertions(+) (limited to 'program/lib/Roundcube/rcube_message.php') diff --git a/CHANGELOG b/CHANGELOG index 9b89a46a9..216a29b67 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ CHANGELOG Roundcube Webmail - Fix PHP warning: Non-static method PEAR::setErrorHandling() should not be called statically (#1490343) - Fix tables listing routine on mysql and postgres so it skips system or other database tables and views (#1490337) - Fix message list header in classic skin on window resize in Internet Explorer (#1490213) +- Fix so text/calendar parts are listed as attachments even if not marked as such (#1490325) RELEASE 1.1.1 ------------- diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index b135ae0ff..449a3c3b4 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -791,6 +791,14 @@ class rcube_message else if ($mail_part->mimetype == 'message/rfc822') { $this->parse_structure($mail_part); } + // calendar part not marked as attachment (#1490325) + else if ($part_mimetype == 'text/calendar') { + if (!$mail_part->filename) { + $mail_part->filename = 'calendar.ics'; + } + + $this->attachments[] = $mail_part; + } } // if this was a related part try to resolve references -- cgit v1.2.3 From 292292df32a5d3f8db2cfc266fb4a8f7dbf52468 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 8 Apr 2015 08:56:42 +0200 Subject: Fix so unrecognized TNEF attachments are displayed on the list of attachments (#1490351) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_message.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'program/lib/Roundcube/rcube_message.php') diff --git a/CHANGELOG b/CHANGELOG index 216a29b67..6dbbecf7a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ CHANGELOG Roundcube Webmail - Fix tables listing routine on mysql and postgres so it skips system or other database tables and views (#1490337) - Fix message list header in classic skin on window resize in Internet Explorer (#1490213) - Fix so text/calendar parts are listed as attachments even if not marked as such (#1490325) +- Fix so unrecognized TNEF attachments are displayed on the list of attachments (#1490351) RELEASE 1.1.1 ------------- diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 449a3c3b4..6c6248ebe 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -739,10 +739,19 @@ class rcube_message } // part is Microsoft Outlook TNEF (winmail.dat) else if ($part_mimetype == 'application/ms-tnef') { - foreach ((array)$this->tnef_decode($mail_part) as $tpart) { + $tnef_parts = (array) $this->tnef_decode($mail_part); + foreach ($tnef_parts as $tpart) { $this->mime_parts[$tpart->mime_id] = $tpart; $this->attachments[] = $tpart; } + + // add winmail.dat to the list if it's content is unknown + if (empty($tnef_parts) && !empty($mail_part->filename)) { + $this->mime_parts[$mail_part->mime_id] = $mail_part; + $this->attachments[] = $mail_part; + } + + $tnef_parts = null; } // part is a file/attachment else if (preg_match('/^(inline|attach)/', $mail_part->disposition) || -- cgit v1.2.3 From d61d668b64c44fc046095b807834c4836a8c05c5 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 8 Apr 2015 08:57:21 +0200 Subject: Remove useless code --- program/lib/Roundcube/rcube_message.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'program/lib/Roundcube/rcube_message.php') diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 6c6248ebe..26248a5b1 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -750,8 +750,6 @@ class rcube_message $this->mime_parts[$mail_part->mime_id] = $mail_part; $this->attachments[] = $mail_part; } - - $tnef_parts = null; } // part is a file/attachment else if (preg_match('/^(inline|attach)/', $mail_part->disposition) || -- cgit v1.2.3 From 5b737d9f8ddd185db1f316d2922dcbcc654706b6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 17 Apr 2015 11:05:06 +0200 Subject: Fix bug where some unrelated attachments in multipart/related message were not listed (#1490355) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_message.php | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'program/lib/Roundcube/rcube_message.php') diff --git a/CHANGELOG b/CHANGELOG index c3049eb73..c6fb09b81 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ CHANGELOG Roundcube Webmail - Fix lack of signature separator for plain text signatures in html mode (#1490352) - Fix font artifact in Google Chrome on Windows (#1490353) - Fix bug where forced extwin page reload could exit from the extwin mode (#1490350) +- Fix bug where some unrelated attachments in multipart/related message were not listed (#1490355) RELEASE 1.1.1 ------------- diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 26248a5b1..441358498 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -579,8 +579,10 @@ class rcube_message $related_part = $p; else if ($sub_mimetype == 'text/plain' && !$plain_part) $plain_part = $p; - else if ($sub_mimetype == 'text/html' && !$html_part) + else if ($sub_mimetype == 'text/html' && !$html_part) { $html_part = $p; + $this->got_html_part = true; + } else if ($sub_mimetype == 'text/enriched' && !$enriched_part) $enriched_part = $p; else { @@ -705,7 +707,7 @@ class rcube_message continue; if ($part_mimetype == 'text/html' && $mail_part->size) { - $got_html_part = true; + $this->got_html_part = true; } $mail_part = $plugin['structure']; @@ -825,7 +827,7 @@ class rcube_message // MS Outlook sends sometimes non-related attachments as related // In this case multipart/related message has only one text part // We'll add all such attachments to the attachments list - if (!isset($got_html_part) && empty($inline_object->content_id)) { + if (!isset($this->got_html_part)) { $this->attachments[] = $inline_object; } // MS Outlook sometimes also adds non-image attachments as related -- cgit v1.2.3