diff options
author | alecpl <alec@alec.pl> | 2008-10-13 07:05:31 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2008-10-13 07:05:31 +0000 |
commit | 2b180b1cceb8e0afb6a8cc091211355a34852f40 (patch) | |
tree | 089a9afa46db7d321cb0a5a77cd1dcf34aa11674 /program/steps/mail | |
parent | 34942eb10424cf678a1db9d2055d8daf57e1a731 (diff) |
#1485494: fixed signatures removal on reply
Diffstat (limited to 'program/steps/mail')
-rw-r--r-- | program/steps/mail/compose.inc | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index ba09fe831..5c6e03f62 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -499,34 +499,38 @@ function rcmail_create_reply_body($body, $bodyIsHtml) if (! $bodyIsHtml) { + // try to remove the signature + if (($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)); + } + // soft-wrap message first $body = rcmail_wrap_quoted($body, 75); - - // split body into single lines - $a_lines = preg_split('/\r?\n/', $body); - - // add > to each line - for($n=0; $n<sizeof($a_lines); $n++) - { - if (strpos($a_lines[$n], '>')===0) - $a_lines[$n] = '>'.$a_lines[$n]; - else - $a_lines[$n] = '> '.$a_lines[$n]; - } + + $body = rtrim($body, "\r\n"); + + if ($body) { + // split body into single lines + $a_lines = preg_split('/\r?\n/', $body); + + // add > to each line + for($n=0; $n<sizeof($a_lines); $n++) { + if (strpos($a_lines[$n], '>')===0) + $a_lines[$n] = '>'.$a_lines[$n]; + else + $a_lines[$n] = '> '.$a_lines[$n]; + } - $body = join("\n", $a_lines); + $body = join("\n", $a_lines); + } // add title line $prefix = sprintf("On %s, %s wrote:\n", $MESSAGE->headers->date, $MESSAGE->get_header('from')); - // try to remove the signature - if ($sp = strrpos($body, '-- ')) - { - if ($body{$sp+3}==' ' || $body{$sp+3}=="\n" || $body{$sp+3}=="\r") - $body = substr($body, 0, $sp-1); - } $suffix = ''; } else |