Aleksander Machniak
2016-03-28 46f7b7096450939fe03c95aa81ce06ae4bfca89d
program/steps/mail/get.inc
@@ -62,10 +62,22 @@
        'messagepartcontrols' => 'rcmail_message_part_controls',
    ));
    $mimetype = $part ? rcmail_fix_mimetype($part->mimetype) : '';
    // message/rfc822 preview (Note: handle also multipart/ parts, they can
    // come from Enigma, which replaces message/rfc822 with real mimetype)
    if ($part_id && ($mimetype == 'message/rfc822' || strpos($mimetype, 'multipart/') === 0)) {
        $uid = preg_replace('/\.[0-9.]+/', '', $uid);
        $uid .= '.' . $part_id;
        $OUTPUT->set_env('is_message', true);
    }
    $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
    $OUTPUT->set_env('uid', $uid);
    $OUTPUT->set_env('part', $part_id);
    $OUTPUT->set_env('filename', $filename);
    $OUTPUT->set_env('mimetype', $mimetype);
    $OUTPUT->send('messagepart');
    exit;
@@ -128,6 +140,10 @@
        if ($plugin['abort']) {
            exit;
        }
        // require CSRF protected url for downloads
        if ($plugin['download'])
            $RCMAIL->request_security_check(rcube_utils::INPUT_GET);
        // overwrite modified vars from plugin
        $mimetype   = $plugin['mimetype'];
@@ -445,12 +461,23 @@
 */
function rcmail_message_part_frame($attrib)
{
    global $MESSAGE, $RCMAIL;
    global $RCMAIL;
    $part = $MESSAGE->mime_parts[asciiwords(rcube_utils::get_input_value('_part', rcube_utils::INPUT_GPC))];
    $ctype_primary = strtolower($part->ctype_primary);
    $attrib['src'] = './?' . str_replace('_frame=', ($ctype_primary=='text' ? '_embed=' : '_preload='), $_SERVER['QUERY_STRING']);
    if ($RCMAIL->output->get_env('is_message')) {
        $attrib['src'] = $RCMAIL->url(array(
                'task'   => 'mail',
                'action' => 'preview',
                'uid'    => $RCMAIL->output->get_env('uid'),
                'mbox'   => $RCMAIL->output->get_env('mailbox'),
                'framed' => 1,
        ));
    }
    else {
        $mimetype      = $RCMAIL->output->get_env('mimetype');
        $frame_replace = strpos($mimetype, 'text/') === 0 ? '_embed=' : '_preload=';
        $attrib['src'] = './?' . str_replace('_frame=', $frame_replace, $_SERVER['QUERY_STRING']);
    }
    $RCMAIL->output->add_gui_object('messagepartframe', $attrib['id']);
@@ -515,12 +542,20 @@
 */
function rcmail_svg_filter($body)
{
    $dom = new DOMDocument;
    $dom->loadXML($body);
    // clean SVG with washhtml
    $wash_opts = array(
        'show_washed'   => false,
        'allow_remote'  => false,
        'charset'       => RCUBE_CHARSET,
        'html_elements' => array('title'),
//        'blocked_src'   => 'program/resources/blocked.gif',
    );
    foreach ($dom->getElementsByTagName('script') as $node) {
        $node->parentNode->removeChild($node);
    }
    // initialize HTML washer
    $washer = new rcube_washtml($wash_opts);
    return $dom->saveXML() ?: '';
    // allow CSS styles, will be sanitized by rcmail_washtml_callback()
    $washer->add_callback('style', 'rcmail_washtml_callback');
    return $washer->wash($body);
}