diff options
author | Aleksander Machniak <alec@alec.pl> | 2014-01-12 09:26:02 +0100 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2014-01-12 09:26:02 +0100 |
commit | 14bd927c71bf6bd62483494b1a4229a50855ccb7 (patch) | |
tree | e394adf3da59d0ee1cd960bcb2bdf757d1221485 /program/steps | |
parent | 3d2320a9584f3008ba4b017ff89bc1d5802e570b (diff) |
Extracting inline image data into attachments also if data type is not set
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/mail/sendmail.inc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index b187d5c5c..0619d630b 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -779,16 +779,15 @@ function rcmail_extract_inline_images($mime_message, $from) $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 +800,10 @@ function rcmail_extract_inline_images($mime_message, $from) $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); |