Aleksander Machniak
2013-05-03 56aeedd9cd844046d9b65582ef69c38941c487fc
Fix bug where multi-level quoting was replaced with one-level quoted text after format=flowed wrapping
3 files modified
18 ■■■■■ changed files
program/lib/Roundcube/rcube_mime.php 14 ●●●●● patch | view | raw | blame | history
tests/src/format-flowed-unfolded.txt 2 ●●● patch | view | raw | blame | history
tests/src/format-flowed.txt 2 ●●● patch | view | raw | blame | history
program/lib/Roundcube/rcube_mime.php
@@ -478,9 +478,10 @@
        $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 @@
        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) . ' ';
tests/src/format-flowed-unfolded.txt
@@ -5,7 +5,7 @@
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.
tests/src/format-flowed.txt
@@ -7,7 +7,7 @@
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.