From 4340d5e63424ffdea2788701c5539c9cdc162eda Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Mon, 12 Nov 2012 03:16:22 -0500 Subject: [PATCH] Fix excessive LFs at the end of composed message with top_posting=true (#1488797) --- CHANGELOG | 1 + program/steps/mail/compose.inc | 10 +++++----- program/steps/mail/func.inc | 2 +- program/js/app.js | 4 ++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 53ac6f3..19585aa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Fix excessive LFs at the end of composed message with top_posting=true (#1488797) - Option to display attached images as thumbnails below message body - Fix bug where leading blanks were stripped from quoted lines (#1488795) - Upgraded to jQuery 1.8.2 and jQuery UI 1.9.1 diff --git a/program/js/app.js b/program/js/app.js index 7764c6c..0f5a60c 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3413,6 +3413,10 @@ message = message.substring(0, p) + sig + message.substring(p, message.length); cursor_pos = p - 1; } + else if (!message) { // empty message + cursor_pos = 0; + message = '\n\n' + sig; + } else if (pos = this.get_caret_pos(input_message.get(0))) { // at cursor position message = message.substring(0, pos) + '\n' + sig + '\n\n' + message.substring(pos, message.length); cursor_pos = pos; diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 2327deb..87a06e1 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -906,9 +906,10 @@ if (!$bodyIsHtml) { $body = preg_replace('/\r?\n/', "\n", $body); + $body = trim($body, "\n"); // soft-wrap and quote message text - $body = rcmail_wrap_and_quote(rtrim($body, "\n"), $LINE_LENGTH); + $body = rcmail_wrap_and_quote($body, $LINE_LENGTH); $prefix .= "\n"; $suffix = ''; @@ -953,8 +954,7 @@ $date = format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long')); $charset = $RCMAIL->output->get_charset(); - if (!$bodyIsHtml) - { + if (!$bodyIsHtml) { $prefix = "\n\n\n-------- " . rcube_label('originalmessage') . " --------\n"; $prefix .= rcube_label('subject') . ': ' . $MESSAGE->subject . "\n"; $prefix .= rcube_label('date') . ': ' . $date . "\n"; @@ -967,9 +967,9 @@ $prefix .= rcube_label('replyto') . ': ' . $MESSAGE->get_header('replyto') . "\n"; $prefix .= "\n"; + $body = trim($body, "\r\n"); } - else - { + else { // set is_safe flag (we need this for html body washing) rcmail_check_safe($MESSAGE); // clean up html tags diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index e4c4d81..5e24a43 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1594,7 +1594,7 @@ $out .= $line . "\n"; } - return $out; + return rtrim($out, "\n"); } -- Gitblit v1.9.1