Thomas Bruederli
2014-04-23 dd5b2c5e6c1b39c151ed9f6689f97dde32b71a6e
program/steps/mail/sendmail.inc
@@ -201,7 +201,7 @@
    $headers['Mail-Reply-To'] = $headers['Reply-To'];
}
if ($hdr = rcube_utils::get_input_value('_followupto', rcube_utils::INPUT_POST, TRUE, $message_charset)) {
    $headers['Mail-Followup-To'] = rcmail_email_input_format();
    $headers['Mail-Followup-To'] = rcmail_email_input_format($hdr);
}
// remember reply/forward UIDs in special headers
@@ -209,7 +209,7 @@
    $headers['X-Draft-Info'] = array('type' => 'reply', 'uid' => $COMPOSE['reply_uid']);
}
else if (!empty($COMPOSE['forward_uid']) && $savedraft) {
    $headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => $COMPOSE['forward_uid']);
    $headers['X-Draft-Info'] = array('type' => 'forward', 'uid' => rcube_imap_generic::compressMessageSet($COMPOSE['forward_uid']));
}
if (!empty($COMPOSE['reply_msgid'])) {
@@ -534,10 +534,16 @@
    }
    // set replied/forwarded flag
    if ($COMPOSE['reply_uid'])
        $RCMAIL->storage->set_flag($COMPOSE['reply_uid'], 'ANSWERED', $COMPOSE['mailbox']);
    else if ($COMPOSE['forward_uid'])
        $RCMAIL->storage->set_flag($COMPOSE['forward_uid'], 'FORWARDED', $COMPOSE['mailbox']);
    if ($COMPOSE['reply_uid']) {
        foreach (rcmail::get_uids($COMPOSE['reply_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
            $RCMAIL->storage->set_flag($uids, 'ANSWERED', $mbox);
        }
    }
    else if ($COMPOSE['forward_uid']) {
        foreach (rcmail::get_uids($COMPOSE['forward_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
            $RCMAIL->storage->set_flag($uids, 'FORWARDED', $mbox);
        }
    }
}
// Determine which folder to save message
@@ -779,16 +785,15 @@
    $body   = $mime_message->getHTMLBody();
    $offset = 0;
    $list   = array();
    $regexp = '# src=[\'"](data:(image/[a-z]+);base64,([a-z0-9+/=\r\n]+))([\'"])#i';
    // get domain for the Content-ID, must be the same as in Mail_Mime::get()
    if (preg_match('#@([0-9a-zA-Z\-\.]+)#', $from, $matches)) {
        $domain = $matches[1];
    } else {
        $domain = 'localhost';
    }
    $domain = 'localhost';
    $regexp = '#img[^>]+src=[\'"](data:([^;]*);base64,([a-z0-9+/=\r\n]+))([\'"])#i';
    if (preg_match_all($regexp, $body, $matches, PREG_OFFSET_CAPTURE)) {
        // get domain for the Content-ID, must be the same as in Mail_Mime::get()
        if (preg_match('#@([0-9a-zA-Z\-\.]+)#', $from, $m)) {
            $domain = $m[1];
        }
        foreach ($matches[1] as $idx => $m) {
            $data = preg_replace('/\r\n/', '', $matches[3][$idx][0]);
            $data = base64_decode($data);
@@ -801,6 +806,10 @@
            $mime_type = $matches[2][$idx][0];
            $name      = $list[$hash];
            if (empty($mime_type)) {
                $mime_type = rcube_mime::image_content_type($data);
            }
            // add the image to the MIME message
            if (!$name) {
                $ext         = preg_replace('#^[^/]+/#', '', $mime_type);