From b488c1d02d00dcaef96146a31f8472b2743a6a71 Mon Sep 17 00:00:00 2001 From: alecpl Date: Wed, 24 Mar 2010 10:06:23 +0000 Subject: - improvements in rcmail_html4inline() --- program/steps/mail/func.inc | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'program/steps') diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index b2e4af3a2..8edd9df8a 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -938,7 +938,7 @@ function rcmail_message_body($attrib) $body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$CONFIG['prefer_html'])); if ($part->ctype_secondary == 'html') - $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'] . ' div.rcmBody')); + $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'], 'div.rcmBody')); else $out .= html::div('message-part', $body); } @@ -997,7 +997,7 @@ function rcmail_resolve_base($body) /** * modify a HTML message that it can be displayed inside a HTML page */ -function rcmail_html4inline($body, $container_id) +function rcmail_html4inline($body, $container_id, $body_id='') { $last_style_pos = 0; $body_lc = strtolower($body); @@ -1008,7 +1008,7 @@ function rcmail_html4inline($body, $container_id) $pos = strpos($body_lc, '>', $pos)+1; // replace all css definitions with #container [def] - $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id); + $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id.($body_id ? ' '.$body_id : '')); $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); $body_lc = strtolower($body); @@ -1020,28 +1020,40 @@ function rcmail_html4inline($body, $container_id) $body = preg_replace_callback('/<(a|link)\s+([^>]+)>/Ui', 'rcmail_alter_html_link', $body); unset($GLOBALS['rcmail_html_container_id']); - // add comments arround html and other tags $out = preg_replace(array( + // add comments arround html and other tags '/(]*>)/i', '/(<\?xml[^>]*>)/i', '/(<\/?html[^>]*>)/i', '/(<\/?head[^>]*>)/i', '/(]*>.*<\/title>)/Ui', - '/(<\/?meta[^>]*>)/i'), - '', + '/(<\/?meta[^>]*>)/i', + // quote /', + // replace with
+ '/]*)>/i', + '/<\/body>/i', + ), + array( + '', + '', + '', + '', + '', + '', + '<?', + '?>', + '
', + '
', + ), $body); - $out = preg_replace( - array('/]*)>/i', '/<\/body>/i'), - array('
', '
'), - $out); - + // make sure there's 'rcmBody' div, we need it for proper css modification + // its name is hardcoded in rcmail_message_body() also if (!preg_match('/
'; - // quote /'), array('<?', '?>'), $out); - return $out; } -- cgit v1.2.3