- Fix use RFC-compliant line-delimiter when saving messages on IMAP (#1486712)

release-0.6
alecpl 15 years ago
parent fc1b7226b4
commit ac8edbed35

@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail CHANGELOG RoundCube Webmail
=========================== ===========================
- Fix use RFC-compliant line-delimiter when saving messages on IMAP (#1486712)
- Add 'imap_timeout' option (#1486760) - Add 'imap_timeout' option (#1486760)
- Fix forwarding of messages with winmail attachments - Fix forwarding of messages with winmail attachments
- Fix handling of uuencoded attachments in message body (#1485839) - Fix handling of uuencoded attachments in message body (#1485839)

@ -216,8 +216,8 @@ $rcmail_config['http_received_header'] = false;
// when tracking down issues. // when tracking down issues.
$rcmail_config['http_received_header_encrypt'] = false; $rcmail_config['http_received_header_encrypt'] = false;
// this string is used as a delimiter for message headers when sending // This string is used as a delimiter for message headers when sending
// leave empty for auto-detection // a message via mail() function. Leave empty for auto-detection
$rcmail_config['mail_header_delimiter'] = NULL; $rcmail_config['mail_header_delimiter'] = NULL;
// number of chars allowed for line when wrapping text. // number of chars allowed for line when wrapping text.

@ -1366,8 +1366,8 @@ function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
if (preg_match_all('/<([^@]+@[^>]+)>/', $headers_enc['To'], $m)) { if (preg_match_all('/<([^@]+@[^>]+)>/', $headers_enc['To'], $m)) {
$headers_enc['To'] = implode(', ', $m[1]); $headers_enc['To'] = implode(', ', $m[1]);
}
} }
}
$msg_body = $message->get(); $msg_body = $message->get();
@ -1376,10 +1376,23 @@ function rcmail_deliver_message(&$message, $from, $mailto, &$smtp_error, &$body_
'file' => __FILE__, 'line' => __LINE__, 'file' => __FILE__, 'line' => __LINE__,
'message' => "Could not create message: ".$msg_body->getMessage()), 'message' => "Could not create message: ".$msg_body->getMessage()),
TRUE, FALSE); TRUE, FALSE);
else if (ini_get('safe_mode')) else {
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); $delim = $RCMAIL->config->header_delimiter();
else $to = $headers_enc['To'];
$sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); $subject = $headers_enc['Subject'];
if ($delim != "\r\n") {
$header_str = str_replace("\r\n", $delim, $header_str);
$msg_body = str_replace("\r\n", $delim, $msg_body);
$to = str_replace("\r\n", $delim, $to);
$subject = str_replace("\r\n", $delim, $subject);
}
if (ini_get('safe_mode'))
$sent = mail($to, $subject, $msg_body, $header_str);
else
$sent = mail($to, $subject, $msg_body, $header_str, "-f$from");
}
} }
if ($sent) { if ($sent) {
@ -1418,7 +1431,7 @@ function rcmail_send_mdn($uid, &$smtp_error)
$recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to)); $recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to));
$mailto = $recipient['mailto']; $mailto = $recipient['mailto'];
$compose = new Mail_mime($RCMAIL->config->header_delimiter()); $compose = new Mail_mime("\r\n");
$compose->setParam('text_encoding', 'quoted-printable'); $compose->setParam('text_encoding', 'quoted-printable');
$compose->setParam('html_encoding', 'quoted-printable'); $compose->setParam('html_encoding', 'quoted-printable');

@ -249,7 +249,7 @@ $headers = array();
// if configured, the Received headers goes to top, for good measure // if configured, the Received headers goes to top, for good measure
if ($CONFIG['http_received_header']) if ($CONFIG['http_received_header'])
{ {
$nldlm = $RCMAIL->config->header_delimiter() . "\t"; $nldlm = "\r\n\t";
// FROM/VIA // FROM/VIA
$http_header = 'from '; $http_header = 'from ';
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
@ -398,7 +398,7 @@ $LINE_LENGTH = $RCMAIL->config->get('line_length', 72);
@set_time_limit(0); @set_time_limit(0);
// create PEAR::Mail_mime instance // create PEAR::Mail_mime instance
$MAIL_MIME = new Mail_mime($RCMAIL->config->header_delimiter()); $MAIL_MIME = new Mail_mime("\r\n");
// Check if we have enough memory to handle the message in it // Check if we have enough memory to handle the message in it
// It's faster than using files, so we'll do this if we only can // It's faster than using files, so we'll do this if we only can
@ -419,7 +419,9 @@ if (is_array($_SESSION['compose']['attachments']) && $CONFIG['smtp_server']
// the HTML part and the plain-text part // the HTML part and the plain-text part
if ($isHtml) { if ($isHtml) {
$plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $message_body, 'type' => 'html', 'message' => $MAIL_MIME)); $plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body',
array('body' => $message_body, 'type' => 'html', 'message' => $MAIL_MIME));
$MAIL_MIME->setHTMLBody($plugin['body'] . ($footer ? "\r\n<pre>".$footer.'</pre>' : '')); $MAIL_MIME->setHTMLBody($plugin['body'] . ($footer ? "\r\n<pre>".$footer.'</pre>' : ''));
// add a plain text version of the e-mail as an alternative part. // add a plain text version of the e-mail as an alternative part.
@ -430,7 +432,14 @@ if ($isHtml) {
// empty message body breaks attachment handling in drafts // empty message body breaks attachment handling in drafts
$plainTextPart = "\r\n"; $plainTextPart = "\r\n";
} }
$plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME)); else {
// make sure all line endings are CRLF (#1486712)
$plainTextPart = preg_replace('/\r?\n/', "\r\n", $plainTextPart);
}
$plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body',
array('body' => $plainTextPart, 'type' => 'alternative', 'message' => $MAIL_MIME));
$MAIL_MIME->setTXTBody($plugin['body']); $MAIL_MIME->setTXTBody($plugin['body']);
// look for "emoticon" images from TinyMCE and change their src paths to // look for "emoticon" images from TinyMCE and change their src paths to
@ -452,7 +461,10 @@ else {
// empty message body breaks attachment handling in drafts // empty message body breaks attachment handling in drafts
$message_body = "\r\n"; $message_body = "\r\n";
} }
$plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body', array('body' => $message_body, 'type' => 'plain', 'message' => $MAIL_MIME));
$plugin = $RCMAIL->plugins->exec_hook('outgoing_message_body',
array('body' => $message_body, 'type' => 'plain', 'message' => $MAIL_MIME));
$MAIL_MIME->setTXTBody($plugin['body'], false, true); $MAIL_MIME->setTXTBody($plugin['body'], false, true);
} }
@ -512,7 +524,7 @@ if (function_exists('mb_encode_mimeheader'))
{ {
mb_internal_encoding($message_charset); mb_internal_encoding($message_charset);
$headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $headers['Subject'] = mb_encode_mimeheader($headers['Subject'],
$message_charset, 'Q', $RCMAIL->config->header_delimiter(), 8); $message_charset, 'Q', "\r\n", 8);
mb_internal_encoding(RCMAIL_CHARSET); mb_internal_encoding(RCMAIL_CHARSET);
} }

Loading…
Cancel
Save