alecpl
2011-11-24 e4a4ca19480690193e36e14ef6b9d592e73e9e9c
- Performance improvements


3 files modified
22 ■■■■■ changed files
program/include/rcube_imap.php 8 ●●●●● patch | view | raw | blame | history
program/include/rcube_template.php 6 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 8 ●●●●● patch | view | raw | blame | history
program/include/rcube_imap.php
@@ -2416,10 +2416,12 @@
        // convert charset (if text or message part)
        if ($body && preg_match('/^(text|message)$/', $o_part->ctype_primary)) {
            // Remove NULL characters (#1486189)
            $body = str_replace("\x00", '', $body);
            // Remove NULL characters if any (#1486189)
            if (strpos($body, "\x00") !== false) {
                $body = str_replace("\x00", '', $body);
            }
           if (!$skip_charset_conv) {
            if (!$skip_charset_conv) {
                if (!$o_part->charset || strtoupper($o_part->charset) == 'US-ASCII') {
                    // try to extract charset information from HTML meta tag (#1488125)
                    if ($o_part->ctype_secondary == 'html' && preg_match('/<meta[^>]+charset=([a-z0-9-_]+)/i', $body, $m))
program/include/rcube_template.php
@@ -434,7 +434,11 @@
        // trigger generic hook where plugins can put additional content to the page
        $hook = $this->app->plugins->exec_hook("render_page", array('template' => $realname, 'content' => $output));
        $output = $this->parse_with_globals($hook['content']);
        // save some memory
        $output = $hook['content'];
        unset($hook['content']);
        $output = $this->parse_with_globals($output);
        // make sure all <form> tags have a valid request token
        $output = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $output);
program/steps/mail/func.inc
@@ -1092,20 +1092,18 @@
function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null)
{
  $last_style_pos = 0;
  $body_lc = strtolower($body);
  $cont_id = $container_id.($body_id ? ' div.'.$body_id : '');
  // find STYLE tags
  while (($pos = strpos($body_lc, '<style', $last_style_pos)) && ($pos2 = strpos($body_lc, '</style>', $pos)))
  while (($pos = stripos($body, '<style', $last_style_pos)) && ($pos2 = stripos($body, '</style>', $pos)))
  {
    $pos = strpos($body_lc, '>', $pos)+1;
    $pos = strpos($body, '>', $pos)+1;
    // replace all css definitions with #container [def]
    $styles = rcmail_mod_css_styles(
      substr($body, $pos, $pos2-$pos), $cont_id);
    $body = substr($body, 0, $pos) . $styles . substr($body, $pos2);
    $body_lc = strtolower($body);
    $body = substr_replace($body, $styles, $pos, $pos2-$pos);
    $last_style_pos = $pos2;
  }