summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-06-05 06:08:46 +0000
committeralec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c>2009-06-05 06:08:46 +0000
commit959e5ec57ab04781e2a328f5dcc3d9b7af302013 (patch)
tree91ab0ee00dc7c4413861f013fdf005b9dc7836ba
parentb8c60c9d297a5abf6a418b8d2fbd6f848f2363f4 (diff)
- fix rep_specialchars_output() performance, remove old 'charset' option use
git-svn-id: https://svn.roundcube.net/trunk@2608 208e9e7b-5314-0410-a742-e7e81cd9613c
-rw-r--r--roundcubemail/program/include/main.inc31
-rw-r--r--roundcubemail/program/include/rcmail.php2
2 files changed, 9 insertions, 24 deletions
diff --git a/roundcubemail/program/include/main.inc b/roundcubemail/program/include/main.inc
index b9408cfa3..6f1be8526 100644
--- a/roundcubemail/program/include/main.inc
+++ b/roundcubemail/program/include/main.inc
@@ -445,18 +445,9 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
static $js_rep_table = false;
static $xml_rep_table = false;
- $charset = rcmail::get_instance()->config->get('charset', RCMAIL_CHARSET);
- $is_iso_8859_1 = false;
- if ($charset == 'ISO-8859-1') {
- $is_iso_8859_1 = true;
- }
if (!$enctype)
$enctype = $OUTPUT->type;
- // encode for plaintext
- if ($enctype=='text')
- return str_replace("\r\n", "\n", $mode=='remove' ? strip_tags($str) : $str);
-
// encode for HTML output
if ($enctype=='html')
{
@@ -486,6 +477,14 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
return $newlines ? nl2br($out) : $out;
}
+ // encode for javascript use
+ if ($enctype=='js')
+ return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table));
+
+ // encode for plaintext
+ if ($enctype=='text')
+ return str_replace("\r\n", "\n", $mode=='remove' ? strip_tags($str) : $str);
+
if ($enctype=='url')
return rawurlencode($str);
@@ -496,12 +495,7 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
$xml_rep_table['&'] = '&amp;';
for ($c=160; $c<256; $c++) // can be increased to support more charsets
- {
$xml_rep_table[Chr($c)] = "&#$c;";
-
- if ($is_iso_8859_1)
- $js_rep_table[Chr($c)] = sprintf("\\u%04x", $c);
- }
$xml_rep_table['"'] = '&quot;';
$js_rep_table['"'] = '\\"';
@@ -513,15 +507,6 @@ function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
if ($enctype=='xml')
return strtr($str, $xml_rep_table);
- // encode for javascript use
- if ($enctype=='js')
- {
- if ($charset!='UTF-8')
- $str = rcube_charset_convert($str, RCMAIL_CHARSET, $charset);
-
- return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table));
- }
-
// no encoding given -> return original string
return $str;
}
diff --git a/roundcubemail/program/include/rcmail.php b/roundcubemail/program/include/rcmail.php
index ea53d914d..afcc33af8 100644
--- a/roundcubemail/program/include/rcmail.php
+++ b/roundcubemail/program/include/rcmail.php
@@ -321,7 +321,7 @@ class rcmail
$this->output->set_env('task', $this->task);
$this->output->set_env('action', $this->action);
$this->output->set_env('comm_path', $this->comm_path);
- $this->output->set_charset($this->config->get('charset', RCMAIL_CHARSET));
+ $this->output->set_charset(RCMAIL_CHARSET);
// add some basic label to client
$this->output->add_label('loading', 'servererror');