File roundcubemail-1.0.9-003-f1ca20d-empty_text_2.patch of Package roundcubemail.openSUSE_13.1_Update
From f1ca20d9934b3999624205fc232f5da7b9973d81 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 28 Jun 2016 09:24:14 +0200
Subject: [PATCH] Don't create multipart/alternative messages with empty
text/plain part (#5283)
Conflicts:
CHANGELOG
program/steps/mail/sendmail.inc
---
CHANGELOG | 1 +
program/steps/mail/sendmail.inc | 21 +++++++++++----------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1f755a0..2843ebe 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Don't create multipart/alternative messages with empty text/plain part (#5283)
- Fix XSS issue in href attribute on area tag (#5240)
RELEASE 1.0.9
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index ac1d789..c1e2611 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -372,18 +372,19 @@ if ($isHtml) {
$plainTextPart = rcube_mime::wordwrap($h2t->get_text(), $LINE_LENGTH, "\r\n", false, $message_charset);
$plainTextPart = wordwrap($plainTextPart, 998, "\r\n", true);
- // completely blank text part confuses some mail clients
- if ($plainTextPart == '') {
- $plainTextPart = "\r\n";
- }
-
- // make sure all line endings are CRLF (#1486712)
- $plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
+ // There's no sense to use multipart/alternative if the text/plain
+ // part would be blank. Completely blank text/plain part may confuse
+ // some mail clients (#5283)
+ if (strlen(trim($plainTextPart)) > 0) {
+ // make sure all line endings are CRLF (#1486712)
+ $plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
- $plugin = $RCMAIL->plugins->exec_hook('message_outgoing_body',
- array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME));
+ $plugin = $RCMAIL->plugins->exec_hook('message_outgoing_body',
+ array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME));
- $MAIL_MIME->setTXTBody($plugin['body']);
+ // add a plain text version of the e-mail as an alternative part.
+ $MAIL_MIME->setTXTBody($plugin['body']);
+ }
// look for "emoticon" images from TinyMCE and change their src paths to
// be file paths on the server instead of URL paths.