Fix flowed conversion with CRLF lineendings.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 May 2009 21:08:34 +0000 (15:08 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 May 2009 21:08:34 +0000 (15:08 -0600)
A couple of minor tweaks also.

framework/Text_Flowed/lib/Horde/Text/Flowed.php

index 5f4d9af..21ebd32 100644 (file)
@@ -195,7 +195,7 @@ class Horde_Text_Flowed
         $opt = $this->_optlength - 1 - $delsp;
 
         /* Process message line by line. */
-        $text = explode("\n", $this->_text);
+        $text = preg_split("/\r?\n/", $this->_text);
         $text_count = count($text) - 1;
         $skip = 0;
         reset($text);
@@ -229,7 +229,7 @@ class Horde_Text_Flowed
                  * line. A line is not flowed if it is a signature line. */
                 if ($line != '-- ') {
                     while (!empty($line) &&
-                           ($line[strlen($line) - 1] == ' ') &&
+                           (substr($line, -1) == ' ') &&
                            ($text_count != $no) &&
                            ($this->_numquotes($text[$no + 1]) == $num_quotes)) {
                         /* If DelSp is yes and this is flowed input, we need to
@@ -351,11 +351,9 @@ class Horde_Text_Flowed
      */
     protected function _unstuff($text)
     {
-        if (!empty($text) && ($text[0] == ' ')) {
-            $text = substr($text, 1);
-        }
-
-        return $text;
+        return (!empty($text) && ($text[0] == ' '))
+            ? substr($text, 1)
+            : $text;
     }
 
 }