From a0682b56d174bc801916f60f85f31f0513b660c6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 23 Nov 2012 03:30:47 -0500
Subject: [PATCH] Fix wrapping of quoted text with format=flowed (#1488177)

---
 CHANGELOG                      |    1 +
 program/include/rcube_mime.php |   10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 64db1eb..61b088d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
 
 - Fix cache (in)validation after setting \Deleted flag
 - Fix keybord events on messages list in opera browser (#1488823)
+- Fix wrapping of quoted text with format=flowed (#1488177)
 
 RELEASE 0.8.4
 -------------
diff --git a/program/include/rcube_mime.php b/program/include/rcube_mime.php
index 287bde8..d33c4eb 100644
--- a/program/include/rcube_mime.php
+++ b/program/include/rcube_mime.php
@@ -540,11 +540,11 @@
 
         foreach ($text as $idx => $line) {
             if ($line != '-- ') {
-                if ($line[0] == '>' && preg_match('/^(>+)/', $line, $regs)) {
-                    $prefix = $regs[0];
-                    $level = strlen($prefix);
-                    $line  = rtrim(substr($line, $level));
-                    $line  = $prefix . rc_wordwrap($line, $length - $level - 2, " \r\n$prefix ");
+                if ($line[0] == '>' && preg_match('/^(>+ {0,1})+/', $line, $regs)) {
+                    $level  = substr_count($regs[0], '>');
+                    $prefix = str_repeat('>', $level) . ' ';
+                    $line   = rtrim(substr($line, strlen($regs[0])));
+                    $line   = $prefix . rc_wordwrap($line, $length - $level - 2, " \r\n$prefix", false, $charset);
                 }
                 else if ($line) {
                     $line = rc_wordwrap(rtrim($line), $length - 2, " \r\n");

--
Gitblit v1.9.1