diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index cf762a4ad..32a701ff0 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1300,28 +1300,30 @@ function rcmail_message_body($attrib) rcmail_message_error($MESSAGE->uid); } - // check if the message body is PGP encrypted - if (strpos($body, '-----BEGIN PGP MESSAGE-----') !== false) { - $OUTPUT->set_env('is_pgp_content', '#message-part' . ($part_no + 1)); - } - $plugin = $RCMAIL->plugins->exec_hook('message_body_prefix', array('part' => $part, 'prefix' => '')); - $body = rcmail_print_body($body, $part, array('safe' => $safe_mode, 'plain' => !$RCMAIL->config->get('prefer_html'))); + // Set attributes of the part container + $container_class = $part->ctype_secondary == 'html' ? 'message-htmlpart' : 'message-part'; + $container_id = $container_class . (++$part_no); + $container_attrib = array('class' => $container_class, 'id' => $container_id); - if ($part->ctype_secondary == 'html') { - $container_id = 'message-htmlpart' . (++$part_no); - $attrs = array('class' => 'message-htmlpart', 'id' => $container_id); - $body = rcmail_html4inline($body, $container_id, 'rcmBody', $attrs, $safe_mode); + // Assign container ID to a global variable for use in rcmail_washtml_link_callback() + $GLOBALS['rcmail_html_container_id'] = $container_id; + + // Parse the part content for display + $body = rcmail_print_body($body, $part, array('safe' => $safe_mode, 'plain' => !$RCMAIL->config->get('prefer_html'))); - $out .= html::div($attrs, $plugin['prefix'] . $body); + // check if the message body is PGP encrypted + if (strpos($body, '-----BEGIN PGP MESSAGE-----') !== false) { + $OUTPUT->set_env('is_pgp_content', '#' . $container_id); } - else { - $container_id = 'message-part' . (++$part_no); - $div_attr = array('class' => 'message-part', 'id' => $container_id); - $out .= html::div($div_attr, $plugin['prefix'] . $body); + + if ($part->ctype_secondary == 'html') { + $body = rcmail_html4inline($body, $container_id, 'rcmBody', $container_attrib, $safe_mode); } + + $out .= html::div($container_attrib, $plugin['prefix'] . $body); } } }