From f5fac810dd2b9276994585789cc68f71c4cd4cd3 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 31 May 2013 05:38:24 -0400
Subject: [PATCH] Fix PHP warning when responding to a message with many Return-Path headers (#1489136)

---
 CHANGELOG                   |    1 +
 program/steps/mail/func.inc |    9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 2c41057..57a7f4a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Fix PHP warning when responding to a message with many Return-Path headers (#1489136)
 - Fix unintentional compose window resize (#1489114)
 - Fix performance regression in text wrapping function (#1489133)
 - Fix connection to posgtres db using unix socket (#1489132)
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 0845bf7..4780056 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1803,9 +1803,12 @@
     // Try Return-Path
     if ($from_idx === null && ($return_path = $MESSAGE->headers->others['return-path'])) {
         foreach ($identities as $idx => $ident) {
-            if (strpos($return_path, str_replace('@', '=', $ident['email_ascii']).'@') !== false) {
-                $from_idx = $idx;
-                break;
+            $ident = str_replace('@', '=', $ident['email_ascii']) . '@';
+            foreach ((array)$return_path as $path) {
+                if (strpos($path, $ident) !== false) {
+                    $from_idx = $idx;
+                    break 2;
+                }
             }
         }
     }

--
Gitblit v1.9.1