From a567d85bf9beb16d8065720769b5920db6236e72 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 19 Jun 2015 03:17:57 -0400
Subject: [PATCH] Fix self-reply detection issues (#1490439)

---
 CHANGELOG                      |    1 +
 program/steps/mail/compose.inc |   15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 2c88e21..c838f49 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,7 @@
 - Fix so plain text signature field uses monospace font (#1490435)
 - Fix so links with href == content aren't added to links list on html to text conversion (#1490434)
 - Fix handling of non-break spaces in html to text conversion (#1490436)
+- Fix self-reply detection issues (#1490439)
 
 RELEASE 1.1.2
 -------------
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index dcfc613..752540d 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -332,12 +332,17 @@
             else if (!empty($MESSAGE->headers->from))
                 $fvalue = $MESSAGE->headers->from;
 
-            // Reply to message sent by yourself (#1487074, #1489230)
+            // Reply to message sent by yourself (#1487074, #1489230, #1490439)
             // Reply-To address need to be unset (#1490233)
-            if (!empty($ident) && empty($replyto)
-                && in_array($ident['ident'], array($fvalue, $MESSAGE->headers->from))
-            ) {
-                $fvalue = $MESSAGE->headers->to;
+            if (!empty($ident) && empty($replyto)) {
+                foreach (array($fvalue, $MESSAGE->headers->from) as $sender) {
+                    $senders = rcube_mime::decode_address_list($sender, null, false, $charset, true);
+
+                    if (in_array($ident['email_ascii'], $senders)) {
+                        $fvalue = $MESSAGE->headers->to;
+                        break;
+                    }
+                }
             }
         }
         // add recipient of original message if reply to all

--
Gitblit v1.9.1