From a4289060e62ece4f4bd35bb00b2d03022afe012c Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 31 Oct 2014 13:31:59 -0400
Subject: [PATCH] Fixed typo

---
 program/steps/mail/sendmail.inc |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index b187d5c..d5f1a7b 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -77,7 +77,7 @@
 $mailcc  = rcmail_email_input_format(rcube_utils::get_input_value('_cc', rcube_utils::INPUT_POST, TRUE, $message_charset), true);
 $mailbcc = rcmail_email_input_format(rcube_utils::get_input_value('_bcc', rcube_utils::INPUT_POST, TRUE, $message_charset), true);
 
-if ($EMAIL_FORMAT_ERROR) {
+if ($EMAIL_FORMAT_ERROR && !$savedraft) {
     $OUTPUT->show_message('emailformaterror', 'error', array('email' => $EMAIL_FORMAT_ERROR));
     $OUTPUT->send('iframe');
 }
@@ -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'])) {
@@ -467,15 +467,11 @@
     $transfer_encoding = $RCMAIL->config->get('force_7bit') ? 'quoted-printable' : '8bit';
 }
 else {
-    $text_charset      = '';
+    $text_charset      = 'US-ASCII';
     $transfer_encoding = '7bit';
 }
 
 if ($flowed) {
-    if (!$text_charset) {
-        $text_charset = 'US-ASCII';
-    }
-
     $text_charset .= ";\r\n format=flowed";
 }
 
@@ -547,7 +543,7 @@
 else if (!$RCMAIL->config->get('no_save_sent_messages')) {
     $store_target = rcube_utils::get_input_value('_store_target', rcube_utils::INPUT_POST);
     if (!strlen($store_target)) {
-        $sore_target = $RCMAIL->config->get('sent_mbox');
+        $store_target = $RCMAIL->config->get('sent_mbox');
     }
 }
 
@@ -779,16 +775,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 +796,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);

--
Gitblit v1.9.1