From fa32c2c47101e1eea561712d3471288ac0a2e038 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 6 Mar 2017 11:35:09 +0100 Subject: [PATCH] Plugin API: Call message_part_structure hook for sub-parts of multipart/alternative message (#5678) --- CHANGELOG | 1 + program/lib/Roundcube/rcube_message.php | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c42087549..9094637e5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Plugin API: Call message_part_structure hook for sub-parts of multipart/alternative message (#5678) - Enigma: Always use detached signatures (#5624) - Enigma: Fix handling of messages with nested PGP encrypted parts (#5634) - Minimize unwanted message loading in preview frame on drag (#5616) diff --git a/program/lib/Roundcube/rcube_message.php b/program/lib/Roundcube/rcube_message.php index 6d3aa494e..7ac31f8bc 100644 --- a/program/lib/Roundcube/rcube_message.php +++ b/program/lib/Roundcube/rcube_message.php @@ -679,8 +679,9 @@ class rcube_message $this->parse_alternative = false; // if plain part was found, we should unset it if html is preferred - if ($this->opt['prefer_html'] && count($this->parts)) + if ($this->opt['prefer_html'] && count($this->parts)) { $plain_part = null; + } } // choose html/plain part to print @@ -697,7 +698,15 @@ class rcube_message // add the right message body if (is_object($print_part)) { $print_part->type = 'content'; - $this->add_part($print_part); + + // Allow plugins to handle also this part + $plugin = $this->app->plugins->exec_hook('message_part_structure', + array('object' => $this, 'structure' => $print_part, + 'mimetype' => $print_part->mimetype, 'recursive' => true)); + + if (!$plugin['abort']) { + $this->add_part($print_part); + } } // show plaintext warning else if ($html_part !== null && empty($this->parts)) {