|
|
|
@ -875,6 +875,8 @@ function rcmail_wash_html($html, $p, $cid_replaces = array())
|
|
|
|
|
'charset' => RCUBE_CHARSET,
|
|
|
|
|
'cid_map' => $cid_replaces,
|
|
|
|
|
'html_elements' => array('body'),
|
|
|
|
|
'css_prefix' => $p['css_prefix'],
|
|
|
|
|
'container_id' => $p['container_id'],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!$p['inline_html']) {
|
|
|
|
@ -886,10 +888,12 @@ function rcmail_wash_html($html, $p, $cid_replaces = array())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// overwrite washer options with options from plugins
|
|
|
|
|
if (isset($p['html_elements']))
|
|
|
|
|
if (isset($p['html_elements'])) {
|
|
|
|
|
$wash_opts['html_elements'] = $p['html_elements'];
|
|
|
|
|
if (isset($p['html_attribs']))
|
|
|
|
|
}
|
|
|
|
|
if (isset($p['html_attribs'])) {
|
|
|
|
|
$wash_opts['html_attribs'] = $p['html_attribs'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// initialize HTML washer
|
|
|
|
|
$washer = new rcube_washtml($wash_opts);
|
|
|
|
@ -908,8 +912,9 @@ function rcmail_wash_html($html, $p, $cid_replaces = array())
|
|
|
|
|
$washer->add_callback('a', 'rcmail_washtml_link_callback');
|
|
|
|
|
$washer->add_callback('area', 'rcmail_washtml_link_callback');
|
|
|
|
|
|
|
|
|
|
if ($p['safe'])
|
|
|
|
|
if ($p['safe']) {
|
|
|
|
|
$washer->add_callback('link', 'rcmail_washtml_link_callback');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove non-UTF8 characters (#1487813)
|
|
|
|
@ -1314,11 +1319,17 @@ function rcmail_message_body($attrib)
|
|
|
|
|
$container_id = $container_class . (++$part_no);
|
|
|
|
|
$container_attrib = array('class' => $container_class, 'id' => $container_id);
|
|
|
|
|
|
|
|
|
|
// Assign container ID to a global variable for use in rcmail_washtml_link_callback()
|
|
|
|
|
$GLOBALS['rcmail_html_container_id'] = $container_id;
|
|
|
|
|
$body_args = array(
|
|
|
|
|
'safe' => $safe_mode,
|
|
|
|
|
'plain' => !$RCMAIL->config->get('prefer_html'),
|
|
|
|
|
'css_prefix' => 'v' . $part_no,
|
|
|
|
|
'body_class' => 'rcmBody',
|
|
|
|
|
'container_id' => $container_id,
|
|
|
|
|
'container_attrib' => $container_attrib,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Parse the part content for display
|
|
|
|
|
$body = rcmail_print_body($body, $part, array('safe' => $safe_mode, 'plain' => !$RCMAIL->config->get('prefer_html')));
|
|
|
|
|
$body = rcmail_print_body($body, $part, $body_args);
|
|
|
|
|
|
|
|
|
|
// check if the message body is PGP encrypted
|
|
|
|
|
if (strpos($body, '-----BEGIN PGP MESSAGE-----') !== false) {
|
|
|
|
@ -1326,7 +1337,7 @@ function rcmail_message_body($attrib)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($part->ctype_secondary == 'html') {
|
|
|
|
|
$body = rcmail_html4inline($body, $container_id, 'rcmBody', $container_attrib, $safe_mode);
|
|
|
|
|
$body = rcmail_html4inline($body, $body_args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$out .= html::div($container_attrib, $plugin['prefix'] . $body);
|
|
|
|
@ -1469,22 +1480,22 @@ function rcmail_part_image_type($part)
|
|
|
|
|
/**
|
|
|
|
|
* Modify a HTML message that it can be displayed inside a HTML page
|
|
|
|
|
*/
|
|
|
|
|
function rcmail_html4inline($body, $container_id, $body_class='', &$attributes=array(), $allow_remote=false)
|
|
|
|
|
function rcmail_html4inline($body, $args)
|
|
|
|
|
{
|
|
|
|
|
$last_style_pos = 0;
|
|
|
|
|
$cont_id = $container_id . ($body_class ? ' div.'.$body_class : '');
|
|
|
|
|
$last_pos = 0;
|
|
|
|
|
$cont_id = $args['container_id'] . ($args['body_class'] ? ' div.' . $args['body_class'] : '');
|
|
|
|
|
|
|
|
|
|
// find STYLE tags
|
|
|
|
|
while (($pos = stripos($body, '<style', $last_style_pos)) && ($pos2 = stripos($body, '</style>', $pos))) {
|
|
|
|
|
while (($pos = stripos($body, '<style', $last_pos)) && ($pos2 = stripos($body, '</style>', $pos))) {
|
|
|
|
|
$pos = strpos($body, '>', $pos) + 1;
|
|
|
|
|
$len = $pos2 - $pos;
|
|
|
|
|
|
|
|
|
|
// replace all css definitions with #container [def]
|
|
|
|
|
$styles = substr($body, $pos, $len);
|
|
|
|
|
$styles = rcube_utils::mod_css_styles($styles, $cont_id, $allow_remote);
|
|
|
|
|
$styles = rcube_utils::mod_css_styles($styles, $cont_id, $args['safe'], $args['css_prefix']);
|
|
|
|
|
|
|
|
|
|
$body = substr_replace($body, $styles, $pos, $len);
|
|
|
|
|
$last_style_pos = $pos2 + strlen($styles) - $len;
|
|
|
|
|
$body = substr_replace($body, $styles, $pos, $len);
|
|
|
|
|
$last_pos = $pos2 + strlen($styles) - $len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$body = preg_replace(array(
|
|
|
|
@ -1511,13 +1522,13 @@ function rcmail_html4inline($body, $container_id, $body_class='', &$attributes=a
|
|
|
|
|
'<!--\\1-->',
|
|
|
|
|
'<?',
|
|
|
|
|
'?>',
|
|
|
|
|
'<div class="' . $body_class . '"\\1>',
|
|
|
|
|
'<div class="' . $args['body_class'] . '"\\1>',
|
|
|
|
|
'</div>',
|
|
|
|
|
),
|
|
|
|
|
$body);
|
|
|
|
|
|
|
|
|
|
// Handle body attributes that doesn't play nicely with div elements
|
|
|
|
|
$regexp = '/<div class="' . preg_quote($body_class, '/') . '"([^>]*)/';
|
|
|
|
|
$regexp = '/<div class="' . preg_quote($args['body_class'], '/') . '"([^>]*)/';
|
|
|
|
|
if (preg_match($regexp, $body, $m)) {
|
|
|
|
|
$style = array();
|
|
|
|
|
$attrs = $m[0];
|
|
|
|
@ -1563,7 +1574,7 @@ function rcmail_html4inline($body, $container_id, $body_class='', &$attributes=a
|
|
|
|
|
// make sure there's 'rcmBody' div, we need it for proper css modification
|
|
|
|
|
// its name is hardcoded in rcmail_message_body() also
|
|
|
|
|
else {
|
|
|
|
|
$body = '<div class="' . $body_class . '">' . $body . '</div>';
|
|
|
|
|
$body = '<div class="' . $args['body_class'] . '">' . $body . '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $body;
|
|
|
|
@ -1586,8 +1597,15 @@ function rcmail_washtml_link_callback($tag, $attribs, $content, $washtml)
|
|
|
|
|
if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href'])) {
|
|
|
|
|
$tempurl = 'tmp-' . md5($attrib['href']) . '.css';
|
|
|
|
|
$_SESSION['modcssurls'][$tempurl] = $attrib['href'];
|
|
|
|
|
$attrib['href'] = $RCMAIL->url(array('task' => 'utils', 'action' => 'modcss', 'u' => $tempurl, 'c' => $GLOBALS['rcmail_html_container_id']));
|
|
|
|
|
$attrib['href'] = $RCMAIL->url(array(
|
|
|
|
|
'task' => 'utils',
|
|
|
|
|
'action' => 'modcss',
|
|
|
|
|
'u' => $tempurl,
|
|
|
|
|
'c' => $washtml->get_config('container_id'),
|
|
|
|
|
'p' => $washtml->get_config('css_prefix'),
|
|
|
|
|
));
|
|
|
|
|
$end = ' />';
|
|
|
|
|
$content = null;
|
|
|
|
|
}
|
|
|
|
|
else if (preg_match('/^mailto:(.+)/i', $attrib['href'], $mailto)) {
|
|
|
|
|
list($mailto, $url) = explode('?', html_entity_decode($mailto[1], ENT_QUOTES, 'UTF-8'), 2);
|
|
|
|
|