Skip to content

Commit

Permalink
Don't create multipart/alternative messages with empty text/plain part (
Browse files Browse the repository at this point in the history
#5283)

Conflicts:
	CHANGELOG
	program/steps/mail/sendmail.inc
  • Loading branch information
alecpl committed Jul 19, 2016
1 parent 7b37ef8 commit f1ca20d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 11 additions & 10 deletions program/steps/mail/sendmail.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit f1ca20d

Please sign in to comment.