From 399a2d68b6529f19898b6d6ef3c05add128aadfa Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 03 Sep 2015 03:28:17 -0400
Subject: [PATCH] Make optional adding of standard signature separator - sig_separator (#1487768)

---
 program/steps/mail/compose.inc |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 807d0ef..488b82e 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -484,7 +484,9 @@
         $top_posting  = intval($RCMAIL->config->get('reply_mode')) > 0
             && !$RCMAIL->config->get('sig_below')
             && ($COMPOSE['mode'] == RCUBE_COMPOSE_REPLY || $COMPOSE['mode'] == RCUBE_COMPOSE_FORWARD);
-        $separator = $top_posting ? '---' : '-- ';
+
+        $separator     = $top_posting ? '---' : '-- ';
+        $add_separator = (bool) $RCMAIL->config->get('sig_separator');
 
         $field_attrib['onchange'] = rcmail_output::JS_OBJECT_NAME.".change_identity(this)";
         $select_from = new html_select($field_attrib);
@@ -500,15 +502,15 @@
 
                 if ($sql_arr['html_signature']) {
                     $text = $RCMAIL->html2text($html, array('links' => false));
-                    $text = trim($text);
+                    $text = trim($text, "\r\n");
                 }
                 else {
                     $t2h  = new rcube_text2html($text, false);
                     $html = $t2h->get_html();
                 }
 
-                if (!preg_match('/^--[ -]\r?\n/m', $text)) {
-                    $text = $separator . "\n" . $text;
+                if ($add_separator && !preg_match('/^--[ -]\r?\n/m', $text)) {
+                    $text = $separator . "\n" . ltrim($text, "\r\n");
                     $html = $separator . "<br>" . $html;
                 }
 

--
Gitblit v1.9.1