From a1e23a896724a50d1e0f73dddaa2ed0da0e2565a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 15 Jul 2016 13:12:42 +0200 Subject: [PATCH] Fix handling of 'mailto' and 'error' arguments in message_before_send hook (#5347) Conflicts: program/lib/Roundcube/rcube.php --- CHANGELOG | 1 + program/lib/Roundcube/rcube.php | 14 +++++++++----- program/steps/mail/sendmail.inc | 14 ++++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b791a3837..e6b48746f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,6 +25,7 @@ CHANGELOG Roundcube Webmail - Fix conflict in new_user_dialog and password_force_new_user settings (#5275) - Don't create multipart/alternative messages with empty text/plain part (#5283) - Use contact_search_name format in popup on results in compose contacts search +- Fix handling of 'mailto' and 'error' arguments in message_before_send hook (#5347) RELEASE 1.2.0 ------------- diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 4de2dd300..451ba569e 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1602,10 +1602,14 @@ class rcube // unset To,Subject headers because they will be added by the mail() function $header_str = $this->message_head($message, array('To', 'Subject')); + if (is_array($mailto)) { + $mailto = implode(', ', $mailto); + } + // #1485779 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - if (preg_match_all('/<([^@]+@[^>]+)>/', $headers['To'], $m)) { - $headers['To'] = implode(', ', $m[1]); + if (preg_match_all('/<([^@]+@[^>]+)>/', $mailto, $m)) { + $mailto = implode(', ', $m[1]); } } @@ -1618,9 +1622,9 @@ class rcube true, false); } else { - $delim = $this->config->header_delimiter(); - $to = $headers['To']; - $subject = $headers['Subject']; + $delim = $this->config->header_delimiter(); + $to = $mailto; + $subject = $headers['Subject']; $header_str = rtrim($header_str); if ($delim != "\r\n") { diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 8ab182a7d..aa77e93fd 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -540,10 +540,16 @@ if (!$savedraft && !$saveonly) { unlink($mailbody_file); } - if ($smtp_error) - $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']); - else - $OUTPUT->show_message('sendingfailed', 'error'); + if ($smtp_error && is_string($smtp_error)) { + $OUTPUT->show_message($smtp_error, 'error'); + } + else if ($smtp_error && !empty($smtp_error['label'])) { + $OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']); + } + else { + $OUTPUT->show_message('sendingfailed', 'error'); + } + $OUTPUT->send('iframe'); }