From 2ce01932fef0abfc6d76dc134024c879a72f9cb7 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
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(-)

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