Ignore:
Timestamp:
Jun 5, 2009 2:08:46 AM (4 years ago)
Author:
alec
Message:
  • fix rep_specialchars_output() performance, remove old 'charset' option use
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/include/main.inc

    r2603 r2608  
    446446  static $xml_rep_table = false; 
    447447 
    448   $charset = rcmail::get_instance()->config->get('charset', RCMAIL_CHARSET); 
    449   $is_iso_8859_1 = false; 
    450   if ($charset == 'ISO-8859-1') { 
    451     $is_iso_8859_1 = true; 
    452   } 
    453448  if (!$enctype) 
    454449    $enctype = $OUTPUT->type; 
    455  
    456   // encode for plaintext 
    457   if ($enctype=='text') 
    458     return str_replace("\r\n", "\n", $mode=='remove' ? strip_tags($str) : $str); 
    459450 
    460451  // encode for HTML output 
     
    487478    } 
    488479 
     480  // encode for javascript use 
     481  if ($enctype=='js') 
     482    return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table)); 
     483 
     484  // encode for plaintext 
     485  if ($enctype=='text') 
     486    return str_replace("\r\n", "\n", $mode=='remove' ? strip_tags($str) : $str); 
     487 
    489488  if ($enctype=='url') 
    490489    return rawurlencode($str); 
     
    497496 
    498497    for ($c=160; $c<256; $c++)  // can be increased to support more charsets 
    499       { 
    500498      $xml_rep_table[Chr($c)] = "&#$c;"; 
    501        
    502       if ($is_iso_8859_1) 
    503         $js_rep_table[Chr($c)] = sprintf("\\u%04x", $c); 
    504       } 
    505499 
    506500    $xml_rep_table['"'] = '&quot;'; 
     
    513507  if ($enctype=='xml') 
    514508    return strtr($str, $xml_rep_table); 
    515  
    516   // encode for javascript use 
    517   if ($enctype=='js') 
    518     { 
    519     if ($charset!='UTF-8') 
    520       $str = rcube_charset_convert($str, RCMAIL_CHARSET, $charset); 
    521        
    522     return preg_replace(array("/\r?\n/", "/\r/", '/<\\//'), array('\n', '\n', '<\\/'), strtr($str, $js_rep_table)); 
    523     } 
    524509 
    525510  // no encoding given -> return original string 
Note: See TracChangeset for help on using the changeset viewer.