Aleksander Machniak
2015-12-16 6402eb7f7880c0c0e5ab87a300808306a695a814
Fix charset encoding of message/rfc822 part bodies (#1490606)
2 files modified
24 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 23 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -3,6 +3,7 @@
- Add workaround for https://bugs.php.net/bug.php?id=70757 (#1490582)
- Fix HTML sanitizer to skip <!-- node type X --> in output (#1490583)
- Fix charset encoding of message/rfc822 part bodies (#1490606)
RELEASE 1.0.7
-------------
program/steps/mail/func.inc
@@ -787,17 +787,22 @@
 * Convert the given message part to proper HTML
 * which can be displayed the message view
 *
 * @param object rcube_message_part Message part
 * @param array  Display parameters array
 * @param rcube_message_part Message part
 * @param array              Display parameters array
 * @param string             Part body
 * @return string Formatted HTML string
 */
function rcmail_print_body($part, $p = array())
function rcmail_print_body($part, $p = array(), $body = null)
{
    global $RCMAIL;
    if ($body === null) {
        $body = $part->body;
    }
    // trigger plugin hook
    $data = $RCMAIL->plugins->exec_hook('message_part_before',
        array('type' => $part->ctype_secondary, 'body' => $part->body, 'id' => $part->mime_id)
        array('type' => $part->ctype_secondary, 'body' => $body, 'id' => $part->mime_id)
            + $p + array('safe' => false, 'plain' => false, 'inline_html' => true));
    // convert html to text/plain
@@ -823,7 +828,7 @@
    }
    else {
        // assert plaintext
        $body = $part->body;
        $body = $data['body'];
        $part->ctype_secondary = $data['type'] = 'plain';
    }
@@ -1200,9 +1205,13 @@
                    $part->body = $MESSAGE->get_part_content($part->mime_id);
                }
                $body = $part->body;
                // extract headers from message/rfc822 parts
                if ($part->mimetype == 'message/rfc822') {
                    $msgpart = rcube_mime::parse_message($part->body);
                    $body    = rcube_charset::convert($msgpart->body, $msgpart->charset);
                    if (!empty($msgpart->headers)) {
                        $part = $msgpart;
                        $out .= html::div('message-partheaders', rcmail_message_headers(sizeof($header_attrib) ? $header_attrib : null, $part->headers));
@@ -1210,14 +1219,14 @@
                }
                // message is cached but not exists (#1485443), or other error
                if ($part->body === false) {
                if ($body === false) {
                    rcmail_message_error($MESSAGE->uid);
                }
                $plugin = $RCMAIL->plugins->exec_hook('message_body_prefix',
                    array('part' => $part, 'prefix' => ''));
                $body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$RCMAIL->config->get('prefer_html')));
                $body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$RCMAIL->config->get('prefer_html')), $body);
                if ($part->ctype_secondary == 'html') {
                    $body     = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $attrs, $safe_mode);