Thomas Bruederli
2015-07-31 2965a981b7ec22866fbdf2d567d87e2d068d3617
program/steps/mail/attachments.inc
@@ -38,7 +38,7 @@
// remove an attachment
if ($RCMAIL->action=='remove-attachment') {
if ($RCMAIL->action == 'remove-attachment') {
    $id = 'undefined';
    if (preg_match('/^rcmfile(\w+)$/', $_POST['_file'], $regs)) {
@@ -60,32 +60,14 @@
    exit;
}
if ($RCMAIL->action=='display-attachment') {
if ($RCMAIL->action == 'display-attachment') {
    $id = 'undefined';
    if (preg_match('/^rcmfile(\w+)$/', $_GET['_file'], $regs)) {
        $id = $regs[1];
    }
    if ($attachment = $COMPOSE['attachments'][$id]) {
        $attachment = $RCMAIL->plugins->exec_hook('attachment_display', $attachment);
    }
    if ($attachment['status']) {
        if (empty($attachment['size'])) {
            $attachment['size'] = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']);
        }
        header('Content-Type: ' . $attachment['mimetype']);
        header('Content-Length: ' . $attachment['size']);
        if ($attachment['data']) {
            echo $attachment['data'];
        }
        else if ($attachment['path']) {
            readfile($attachment['path']);
        }
    }
    $RCMAIL->display_uploaded_file($COMPOSE['attachments'][$id]);
    exit;
}
@@ -139,6 +121,7 @@
                'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", rcmail_output::JS_OBJECT_NAME, $id),
                'title'   => $RCMAIL->gettext('delete'),
                'class'   => 'delete',
                'aria-label' => $RCMAIL->gettext('delete') . ' ' . $attachment['name'],
            ), $button);
            $content .= rcube::Q($attachment['name']);