From e019f2d0f2dc2fbfa345ab5d7ae85e67bfdd76b8 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Sat, 25 Sep 2010 09:03:53 -0400
Subject: [PATCH] - s/RoundCube/Roundcube/

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

diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 6150fff..521a0f7 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -4,8 +4,8 @@
  +-----------------------------------------------------------------------+
  | program/steps/mail/compose.inc                                        |
  |                                                                       |
- | This file is part of the RoundCube Webmail client                     |
- | Copyright (C) 2005-2009, RoundCube Dev. - Switzerland                 |
+ | This file is part of the Roundcube Webmail client                     |
+ | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland                 |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  | PURPOSE:                                                              |
@@ -610,14 +610,24 @@
   global $RCMAIL, $MESSAGE, $LINE_LENGTH;
 
   if (!$bodyIsHtml) {
+    $body = preg_replace('/\r?\n/', "\n", $body);
+  
     // try to remove the signature
-    if ($RCMAIL->config->get('strip_existing_sig', true) && ($sp = strrpos($body, '-- ')) !== false && ($sp == 0 || $body{$sp-1} == "\n")) {
-      if ($body{$sp+3}==' ' || $body{$sp+3}=="\n" || $body{$sp+3}=="\r")
-        $body = substr($body, 0, max(0, $sp-1));
+    if ($RCMAIL->config->get('strip_existing_sig', true)) {
+      $len = strlen($body);
+      while (($sp = strrpos($body, "-- \n", $sp ? -$len+$sp-1 : 0)) !== false) {
+        if ($sp == 0 || $body[$sp-1] == "\n") {
+          // do not touch blocks with more that X lines
+          if (substr_count($body, "\n", $sp) < $RCMAIL->config->get('sig_max_lines', 15)) {
+            $body = substr($body, 0, max(0, $sp-1));
+          }
+          break;
+        }
+      }
     }
 
     // soft-wrap and quote message text
-    $body = rcmail_wrap_and_quote(rtrim($body, "\r\n"), $LINE_LENGTH);
+    $body = rcmail_wrap_and_quote(rtrim($body, "\n"), $LINE_LENGTH);
 
     // add title line(s)
     $prefix = sprintf("On %s, %s wrote:\n",

--
Gitblit v1.9.1