From b2d4cfa89a9d498f98b5d19ac496cf9f70f92070 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 09 Feb 2016 03:10:32 -0500
Subject: [PATCH] Fix additional_message_headers plugin compatibility with Mail_Mime >= 1.9 (#1490657)

---
 CHANGELOG                                                         |    1 +
 plugins/additional_message_headers/composer.json                  |    2 +-
 plugins/additional_message_headers/package.xml                    |    2 +-
 plugins/additional_message_headers/additional_message_headers.php |   16 ++++------------
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 38497c0..6919600 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@
 - Fix (again) security issue in DBMail driver of password plugin [CVE-2015-2181] (#1490643)
 - Fix bug where Archive/Junk buttons were not active after page jump with select=all mode (#1490647)
 - Fix bug in long recipients list parsing for cases where recipient name contained @-char (#1490653)
+- Fix additional_message_headers plugin compatibility with Mail_Mime >= 1.9 (#1490657)
 
 RELEASE 1.0.8
 -------------
diff --git a/plugins/additional_message_headers/additional_message_headers.php b/plugins/additional_message_headers/additional_message_headers.php
index 0d16e60..58e4d41 100644
--- a/plugins/additional_message_headers/additional_message_headers.php
+++ b/plugins/additional_message_headers/additional_message_headers.php
@@ -24,22 +24,14 @@
     {
         $this->load_config();
 
-        $headers = $args['message']->headers();
-        $rcube   = rcube::get_instance();
+        $rcube = rcube::get_instance();
 
         // additional email headers
         $additional_headers = $rcube->config->get('additional_message_headers', array());
-        foreach ((array)$additional_headers as $header => $value) {
-            if (null === $value) {
-                unset($headers[$header]);
-            }
-            else {
-                $headers[$header] = $value;
-            }
-        }
 
-        $args['message']->_headers = array();
-        $args['message']->headers($headers);
+        if (!empty($additional_headers)) {
+            $args['message']->headers($additional_headers, true);
+        }
 
         return $args;
     }
diff --git a/plugins/additional_message_headers/composer.json b/plugins/additional_message_headers/composer.json
index 04cd9e4..fa82b55 100644
--- a/plugins/additional_message_headers/composer.json
+++ b/plugins/additional_message_headers/composer.json
@@ -3,7 +3,7 @@
     "type": "roundcube-plugin",
     "description": "Very simple plugin which will add additional headers to or remove them from outgoing messages.",
     "license": "GNU GPL v2",
-    "version": "1.2.0",
+    "version": "1.2.1",
     "authors": [
         {
             "name": "Ziba Scott",
diff --git a/plugins/additional_message_headers/package.xml b/plugins/additional_message_headers/package.xml
index c15d9f8..dcacf56 100644
--- a/plugins/additional_message_headers/package.xml
+++ b/plugins/additional_message_headers/package.xml
@@ -16,7 +16,7 @@
  <date>2013-08-25</date>
  <version>
   <release>1.2.0</release>
-  <api>1.2.0</api>
+  <api>1.2.1</api>
  </version>
  <stability>
   <release>stable</release>

--
Gitblit v1.9.1