From afd090672c2f45f7d6ca32493846b887c667dacc Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 08 May 2016 05:52:54 -0400
Subject: [PATCH] Small performance optimization
---
tests/Framework/Text2Html.php | 1 +
program/lib/Roundcube/rcube_text2html.php | 9 +++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/program/lib/Roundcube/rcube_text2html.php b/program/lib/Roundcube/rcube_text2html.php
index 6bdbb8f..73e8b78 100644
--- a/program/lib/Roundcube/rcube_text2html.php
+++ b/program/lib/Roundcube/rcube_text2html.php
@@ -270,6 +270,10 @@
if (empty($table)) {
$table = get_html_translation_table(HTML_SPECIALCHARS);
unset($table['?']);
+
+ // replace some whitespace characters
+ $table["\r"] = '';
+ $table["\t"] = ' ';
}
// skip signature separator
@@ -277,11 +281,8 @@
return '--' . $this->config['space'];
}
- // replace HTML special characters
+ // replace HTML special and whitespace characters
$text = strtr($text, $table);
-
- // replace some whitespace characters
- $text = str_replace(array("\r", "\t"), array('', ' '), $text);
$nbsp = $this->config['space'];
diff --git a/tests/Framework/Text2Html.php b/tests/Framework/Text2Html.php
index a08f9c0..03c4bd0 100644
--- a/tests/Framework/Text2Html.php
+++ b/tests/Framework/Text2Html.php
@@ -46,6 +46,7 @@
$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\r\tcccc", ">aaaa-bbbb____cccc<", $options);
$options['flowed'] = true;
--
Gitblit v1.9.1