From f189d72943c490ae97323997aef8987bc58f3b5e Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 10 Sep 2015 15:27:58 -0400
Subject: [PATCH] Merged branch 'dev-mailvelope'

---
 program/steps/mail/func.inc |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 909b870..09cf6ed 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1193,7 +1193,23 @@
                 // unsupported (e.g. encrypted)
                 if ($part->realtype) {
                     if ($part->realtype == 'multipart/encrypted' || $part->realtype == 'application/pkcs7-mime') {
-                        $out .= html::span('part-notice', $RCMAIL->gettext('encryptedmessage'));
+                        if (!empty($_SESSION['browser_caps']['pgpmime']) && $part->realtype == 'multipart/encrypted') {
+                            // find the encrypted message payload part
+                            foreach ($MESSAGE->mime_parts as $mime_id => $mpart) {
+                                if ($mpart->mimetype == 'application/octet-stream' || !empty($mpart->filename)) {
+                                    $out .= html::span('part-notice', $RCMAIL->gettext('externalmessagedecryption'));
+                                    $OUTPUT->set_env('pgp_mime_part', $mime_id);
+                                    $OUTPUT->set_env('pgp_mime_container', '#' . $attrib['id']);
+                                    $OUTPUT->add_label('loadingdata');
+                                    $MESSAGE->encrypted_part = $mime_id;
+                                    break;
+                                }
+                            }
+                        }
+
+                        if (!$MESSAGE->encrypted_part) {
+                            $out .= html::span('part-notice', $RCMAIL->gettext('encryptedmessage'));
+                        }
                     }
                     continue;
                 }
@@ -1227,6 +1243,11 @@
                     rcmail_message_error($MESSAGE->uid);
                 }
 
+                // check if the message body is PGP encrypted
+                if (strpos($body, 'BEGIN PGP MESSAGE') !== false) {
+                    $OUTPUT->set_env('is_pgp_content', '#' . $attrib['id']);
+                }
+
                 $plugin = $RCMAIL->plugins->exec_hook('message_body_prefix',
                     array('part' => $part, 'prefix' => ''));
 

--
Gitblit v1.9.1