From 22c0b291f6bd90915e4ea48c831d268b37fa5db5 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 09 Apr 2015 09:56:45 -0400
Subject: [PATCH] Fix font artifact in Google Chrome on Windows (#1490353)
---
CHANGELOG | 1 +
tests/Framework/Text2Html.php | 2 +-
program/lib/Roundcube/rcube_text2html.php | 27 +++++++++++++++++++--------
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 8236ab2..1510fa6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
- Fix message list header in classic skin on window resize in Internet Explorer (#1490213)
- Fix so text/calendar parts are listed as attachments even if not marked as such (#1490325)
- Fix lack of signature separator for plain text signatures in html mode (#1490352)
+- Fix font artifact in Google Chrome on Windows (#1490353)
RELEASE 1.1.1
-------------
diff --git a/program/lib/Roundcube/rcube_text2html.php b/program/lib/Roundcube/rcube_text2html.php
index 1981b2f..2ffe530 100644
--- a/program/lib/Roundcube/rcube_text2html.php
+++ b/program/lib/Roundcube/rcube_text2html.php
@@ -45,18 +45,22 @@
*/
protected $config = array(
// non-breaking space
- 'space' => "\xC2\xA0",
+ 'space' => "\xC2\xA0",
+ // word-joiner (zero-width no-break space)
+ // 'wordjoiner' => "\xEF\xBB\xBF", // U+2060
+ // use deprecated U+FEFF character because of webkit issue with displaying U+2060 (#1490353)
+ 'wordjoiner' => "\xEF\xBB\xBF", // U+FEFF
// enables format=flowed parser
'flowed' => false,
// enables wrapping for non-flowed text
- 'wrap' => true,
+ 'wrap' => true,
// line-break tag
- 'break' => "<br>\n",
+ 'break' => "<br>\n",
// prefix and suffix (wrapper element)
- 'begin' => '<div class="pre">',
- 'end' => '</div>',
+ 'begin' => '<div class="pre">',
+ 'end' => '</div>',
// enables links replacement
- 'links' => true,
+ 'links' => true,
// string replacer class
'replacer' => 'rcube_string_replacer',
);
@@ -278,6 +282,7 @@
$text = strtr($text, $table);
$nbsp = $this->config['space'];
+ $nobr = $this->config['wordjoiner'];
// replace some whitespace characters
$text = str_replace(array("\r", "\t"), array('', ' '), $text);
@@ -299,9 +304,15 @@
$text = $copy;
}
+ // make the whole line non-breakable
else {
- // make the whole line non-breakable
- $text = str_replace(array(' ', '-', '/'), array($nbsp, '-⁠', '/⁠'), $text);
+ $repl = array(
+ ' ' => $nbsp,
+ '-' => $nobr . '-' . $nobr,
+ '/' => $nobr . '/',
+ );
+
+ $text = str_replace(array_keys($repl), array_values($repl), $text);
}
return $text;
diff --git a/tests/Framework/Text2Html.php b/tests/Framework/Text2Html.php
index 8d1325d..771e147 100644
--- a/tests/Framework/Text2Html.php
+++ b/tests/Framework/Text2Html.php
@@ -41,7 +41,7 @@
$data[] = array(">aaaa \n>aaaa", "<blockquote>aaaa_<br>aaaa</blockquote>", $options);
$data[] = array(">aaaa\n>aaaa", "<blockquote>aaaa<br>aaaa</blockquote>", $options);
$data[] = array(">aaaa \n>bbbb\ncccc dddd", "<blockquote>aaaa_<br>bbbb</blockquote>cccc_dddd", $options);
- $data[] = array("aaaa-bbbb/cccc", "aaaa-⁠bbbb/⁠cccc", $options);
+ $data[] = array("aaaa-bbbb/cccc", "aaaa\xEF\xBB\xBF-\xEF\xBB\xBFbbbb\xEF\xBB\xBF/cccc", $options);
$options['flowed'] = true;
--
Gitblit v1.9.1