From d2dff5e86505675961bf5a847e7a502b8131dee6 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 1 May 2013 11:11:39 +0200 Subject: Fix Reply-To header handling in Reply-All action (#1489037) --- program/lib/Roundcube/rcube_mime.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'program/lib/Roundcube/rcube_mime.php') diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php index 96296a57c..0a4bfbddb 100644 --- a/program/lib/Roundcube/rcube_mime.php +++ b/program/lib/Roundcube/rcube_mime.php @@ -127,10 +127,11 @@ class rcube_mime * @param int $max List only this number of addresses * @param boolean $decode Decode address strings * @param string $fallback Fallback charset if none specified + * @param boolean $addronly Return flat array with e-mail addresses only * - * @return array Indexed list of addresses + * @return array Indexed list of addresses */ - static function decode_address_list($input, $max = null, $decode = true, $fallback = null) + static function decode_address_list($input, $max = null, $decode = true, $fallback = null, $addronly = false) { $a = self::parse_address_list($input, $decode, $fallback); $out = array(); @@ -145,20 +146,21 @@ class rcube_mime foreach ($a as $val) { $j++; $address = trim($val['address']); - $name = trim($val['name']); - - if ($name && $address && $name != $address) - $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); - else if ($address) - $string = $address; - else if ($name) - $string = $name; - - $out[$j] = array( - 'name' => $name, - 'mailto' => $address, - 'string' => $string - ); + + if ($addronly) { + $out[$j] = $address; + } + else { + $name = trim($val['name']); + if ($name && $address && $name != $address) + $string = sprintf('%s <%s>', preg_match("/$special_chars/", $name) ? '"'.addcslashes($name, '"').'"' : $name, $address); + else if ($address) + $string = $address; + else if ($name) + $string = $name; + + $out[$j] = array('name' => $name, 'mailto' => $address, 'string' => $string); + } if ($max && $j==$max) break; -- cgit v1.2.3 From 2ce01932fef0abfc6d76dc134024c879a72f9cb7 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 3 May 2013 08:24:26 +0200 Subject: Fix another text wrap issue (added test case) --- program/lib/Roundcube/rcube_mime.php | 4 ++-- tests/Framework/Mime.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'program/lib/Roundcube/rcube_mime.php') diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php index 0a4bfbddb..53724cbba 100644 --- a/program/lib/Roundcube/rcube_mime.php +++ b/program/lib/Roundcube/rcube_mime.php @@ -659,8 +659,8 @@ class rcube_mime $cutLength = $spacePos + 1; } else { - $subString = $string; - $cutLength = null; + $subString = $substr_func($string, 0, $breakPos, $charset); + $cutLength = $breakPos + 1; } } else { diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php index 61123dd85..3035ba062 100644 --- a/tests/Framework/Mime.php +++ b/tests/Framework/Mime.php @@ -185,6 +185,10 @@ class Framework_Mime extends PHPUnit_Framework_TestCase array("----------------------------------------------------------------------------------------\nabc def123456789012345", 76), "----------------------------------------------------------------------------------------\nabc def123456789012345", ), + array( + array("-------\nabc def", 5), + "-------\nabc\ndef", + ), ); foreach ($samples as $sample) { -- cgit v1.2.3 From b92ec5c86d2f85c43705ada6fbcb8912f48907f0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 3 May 2013 09:26:13 +0200 Subject: Fix bug where multi-level quoting was replaced with one-level quoted text after format=flowed wrapping --- program/lib/Roundcube/rcube_mime.php | 14 ++++++++------ tests/src/format-flowed-unfolded.txt | 2 +- tests/src/format-flowed.txt | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'program/lib/Roundcube/rcube_mime.php') 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. -- cgit v1.2.3