summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-10-12 13:03:31 +0200
committerAleksander Machniak <alec@alec.pl>2013-10-12 13:05:27 +0200
commit571aa9b04ea6345acc98e1671a8ebcfd7abb4f62 (patch)
tree0988483ad9185c64e54886b44f02265d89204491
parent42173df79e16c7ce43c29652e0ef3847b8147a6e (diff)
Fix text wrapping issue with long unwrappable lines (#1489371)
Conflicts: CHANGELOG
-rw-r--r--CHANGELOG1
-rw-r--r--program/lib/Roundcube/rcube_mime.php14
-rw-r--r--tests/Framework/Mime.php4
3 files changed, 12 insertions, 7 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 74ddb7240..2554ec09b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix text wrapping issue with long unwrappable lines (#1489371)
- Fixed mispelling: occured -> occurred (#1489366)
- Fixed issues where HTML comments inside style tag would hang Internet Explorer
- Fix setting domain in virtualmin password driver (#1489332)
diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php
index 572540f47..323a5e900 100644
--- a/program/lib/Roundcube/rcube_mime.php
+++ b/program/lib/Roundcube/rcube_mime.php
@@ -637,7 +637,8 @@ class rcube_mime
if ($nextChar === ' ' || $nextChar === $separator) {
$afterNextChar = mb_substr($string, $width + 1, 1);
- if ($afterNextChar === false) {
+ // Note: mb_substr() does never return False
+ if ($afterNextChar === false || $afterNextChar === '') {
$subString .= $nextChar;
}
@@ -650,24 +651,23 @@ class rcube_mime
$subString = mb_substr($subString, 0, $spacePos);
$cutLength = $spacePos + 1;
}
- else if ($cut === false && $breakPos === false) {
- $subString = $string;
- $cutLength = null;
- }
else if ($cut === false) {
$spacePos = mb_strpos($string, ' ', 0);
- if ($spacePos !== false && $spacePos < $breakPos) {
+ if ($spacePos !== false && ($breakPos === false || $spacePos < $breakPos)) {
$subString = mb_substr($string, 0, $spacePos);
$cutLength = $spacePos + 1;
}
+ else if ($breakPos === false) {
+ $subString = $string;
+ $cutLength = null;
+ }
else {
$subString = mb_substr($string, 0, $breakPos);
$cutLength = $breakPos + 1;
}
}
else {
- $subString = mb_substr($subString, 0, $width);
$cutLength = $width;
}
}
diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php
index 4db1856be..1450b4f90 100644
--- a/tests/Framework/Mime.php
+++ b/tests/Framework/Mime.php
@@ -197,6 +197,10 @@ class Framework_Mime extends PHPUnit_Framework_TestCase
array("http://xx.xxx.xx.xxx:8080/addressbooks/roundcubexxxxx%40xxxxxxxxxxxxxxxxxxxxxxx.xx.xx/testing/", 70),
"http://xx.xxx.xx.xxx:8080/addressbooks/roundcubexxxxx%40xxxxxxxxxxxxxxxxxxxxxxx.xx.xx/testing/",
),
+ array(
+ array("this-is-just-some-blabla-to-make-this-more-than-seventy-five-characters-in-a-row -- this line should be wrapped", 20, "\n"),
+ "this-is-just-some-blabla-to-make-this-more-than-seventy-five-characters-in-a-row\n-- this line should\nbe wrapped",
+ ),
);
foreach ($samples as $sample) {