summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-05-03 09:26:13 +0200
committerAleksander Machniak <alec@alec.pl>2013-05-03 09:26:13 +0200
commitb92ec5c86d2f85c43705ada6fbcb8912f48907f0 (patch)
tree3d4ec17671bcb46817cda58a396138e16de452d4
parent2ce01932fef0abfc6d76dc134024c879a72f9cb7 (diff)
Fix bug where multi-level quoting was replaced with one-level quoted text after format=flowed wrapping
-rw-r--r--program/lib/Roundcube/rcube_mime.php14
-rw-r--r--tests/src/format-flowed-unfolded.txt2
-rw-r--r--tests/src/format-flowed.txt2
3 files changed, 10 insertions, 8 deletions
diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php
index 53724cbba..63549fbec 100644
--- a/program/lib/Roundcube/rcube_mime.php
+++ b/program/lib/Roundcube/rcube_mime.php
@@ -478,9 +478,10 @@ class rcube_mime
$q_level = 0;
foreach ($text as $idx => $line) {
- if ($line[0] == '>') {
- // remove quote chars, store level in $q
- $line = preg_replace('/^>+/', '', $line, -1, $q);
+ if (preg_match('/^(>+)/', $line, $m)) {
+ // remove quote chars
+ $q = strlen($m[1]);
+ $line = preg_replace('/^>+/', '', $line);
// remove (optional) space-staffing
$line = preg_replace('/^ /', '', $line);
@@ -543,9 +544,10 @@ class rcube_mime
foreach ($text as $idx => $line) {
if ($line != '-- ') {
- if ($line[0] == '>') {
- // remove quote chars, store level in $level
- $line = preg_replace('/^>+/', '', $line, -1, $level);
+ if (preg_match('/^(>+)/', $line, $m)) {
+ // remove quote chars
+ $level = strlen($m[1]);
+ $line = preg_replace('/^>+/', '', $line);
// remove (optional) space-staffing and spaces before the line end
$line = preg_replace('/(^ | +$)/', '', $line);
$prefix = str_repeat('>', $level) . ' ';
diff --git a/tests/src/format-flowed-unfolded.txt b/tests/src/format-flowed-unfolded.txt
index 14e526be4..0af9b7130 100644
--- a/tests/src/format-flowed-unfolded.txt
+++ b/tests/src/format-flowed-unfolded.txt
@@ -5,7 +5,7 @@ X
On XX.YY.YYYY Y:YY, Somebody wrote:
> This part is a reply wihtout any flowing lines. rcube_mime::unfold_flowed()
-> has to be careful with empty quoted lines because they might end with a
+>> has to be careful with empty quoted lines because they might end with a
> space but still shouldn't be considered as flowed!
>
> The above empty line should persist after unfolding.
diff --git a/tests/src/format-flowed.txt b/tests/src/format-flowed.txt
index 359a41aec..da36064e0 100644
--- a/tests/src/format-flowed.txt
+++ b/tests/src/format-flowed.txt
@@ -7,7 +7,7 @@ X
On XX.YY.YYYY Y:YY, Somebody wrote:
> This part is a reply wihtout any flowing lines. rcube_mime::unfold_flowed()
-> has to be careful with empty quoted lines because they might end with a
+>> has to be careful with empty quoted lines because they might end with a
> space but still shouldn't be considered as flowed!
>
> The above empty line should persist after unfolding.