- Fix forwarding of messages with winmail attachments

- Remove some redundant code for winmail handling in get.inc, move tnef_decode() to rcube_message
- Fix handling of uuencoded attachments in message body (#1485839)
- Extend rc_mime_content_type() to work with string buffer
release-0.6
alecpl 15 years ago
parent 89e31bec15
commit d311d809d6

@ -1,6 +1,8 @@
CHANGELOG RoundCube Webmail CHANGELOG RoundCube Webmail
=========================== ===========================
- Fix forwarding of messages with winmail attachments
- Fix handling of uuencoded attachments in message body (#1485839)
- Added list_mailboxes hook in rcube_imap::list_unsubscribed() (#1486668) - Added list_mailboxes hook in rcube_imap::list_unsubscribed() (#1486668)
- Fix wrong message on file upload error (#1486725) - Fix wrong message on file upload error (#1486725)
- Add support for data URI scheme [RFC2397] (#1486740) - Add support for data URI scheme [RFC2397] (#1486740)

@ -472,7 +472,6 @@ class rcube_imap
// get message count and store in cache // get message count and store in cache
if ($mode == 'UNSEEN') if ($mode == 'UNSEEN')
$search_str .= " UNSEEN"; $search_str .= " UNSEEN";
// get message count using SEARCH // get message count using SEARCH
// not very performant but more precise (using UNDELETED) // not very performant but more precise (using UNDELETED)
// disable THREADS for this request // disable THREADS for this request
@ -2034,7 +2033,7 @@ class rcube_imap
return true; return true;
// convert charset (if text or message part) // convert charset (if text or message part)
if ($o_part->ctype_primary=='text' || $o_part->ctype_primary=='message') { if ($o_part->ctype_primary == 'text' || $o_part->ctype_primary == 'message') {
// assume default if no charset specified // assume default if no charset specified
if (empty($o_part->charset) || strtolower($o_part->charset) == 'us-ascii') if (empty($o_part->charset) || strtolower($o_part->charset) == 'us-ascii')
$o_part->charset = $this->default_charset; $o_part->charset = $this->default_charset;
@ -3382,43 +3381,6 @@ class rcube_imap
} }
/**
* Decode a Microsoft Outlook TNEF part (winmail.dat)
*
* @param object rcube_message_part Message part to decode
* @param string UID of the message
* @return array List of rcube_message_parts extracted from windmail.dat
*/
function tnef_decode(&$part, $uid)
{
if (!isset($part->body))
$part->body = $this->get_message_part($uid, $part->mime_id, $part);
require_once('lib/tnef_decoder.inc');
$pid = 0;
$tnef_parts = array();
$tnef_arr = tnef_decode($part->body);
foreach ($tnef_arr as $winatt) {
$tpart = new rcube_message_part;
$tpart->filename = trim($winatt['name']);
$tpart->encoding = 'stream';
$tpart->ctype_primary = trim(strtolower($winatt['type0']));
$tpart->ctype_secondary = trim(strtolower($winatt['type1']));
$tpart->mimetype = $tpart->ctype_primary . '/' . $tpart->ctype_secondary;
$tpart->mime_id = "winmail." . $part->mime_id . ".$pid";
$tpart->size = $winatt['size'];
$tpart->body = $winatt['stream'];
$tnef_parts[] = $tpart;
$pid++;
}
return $tnef_parts;
}
/** /**
* Decode a message header value * Decode a message header value
* *

File diff suppressed because it is too large Load Diff

@ -430,16 +430,17 @@ function abbreviate_string($str, $maxlength, $place_holder='...')
/** /**
* A method to guess the mime_type of an attachment. * A method to guess the mime_type of an attachment.
* *
* @param string $path Path to the file. * @param string $path Path to the file.
* @param string $name File name (with suffix) * @param string $name File name (with suffix)
* @param string $failover Mime type supplied for failover. * @param string $failover Mime type supplied for failover.
* @param string $is_stream Set to True if $path contains file body
* *
* @return string * @return string
* @author Till Klampaeckel <till@php.net> * @author Till Klampaeckel <till@php.net>
* @see http://de2.php.net/manual/en/ref.fileinfo.php * @see http://de2.php.net/manual/en/ref.fileinfo.php
* @see http://de2.php.net/mime_content_type * @see http://de2.php.net/mime_content_type
*/ */
function rc_mime_content_type($path, $name, $failover = 'application/octet-stream') function rc_mime_content_type($path, $name, $failover = 'application/octet-stream', $is_stream=false)
{ {
$mime_type = null; $mime_type = null;
$mime_magic = rcmail::get_instance()->config->get('mime_magic'); $mime_magic = rcmail::get_instance()->config->get('mime_magic');
@ -453,13 +454,16 @@ function rc_mime_content_type($path, $name, $failover = 'application/octet-strea
// try fileinfo extension if available // try fileinfo extension if available
if (!$mime_type && function_exists('finfo_open')) { if (!$mime_type && function_exists('finfo_open')) {
if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) { if ($finfo = finfo_open(FILEINFO_MIME, $mime_magic)) {
$mime_type = finfo_file($finfo, $path); if ($is_stream)
$mime_type = finfo_buffer($finfo, $path);
else
$mime_type = finfo_file($finfo, $path);
finfo_close($finfo); finfo_close($finfo);
} }
} }
// try PHP's mime_content_type // try PHP's mime_content_type
if (!$mime_type && function_exists('mime_content_type')) { if (!$mime_type && !$is_stream && function_exists('mime_content_type')) {
$mime_type = mime_content_type($path); $mime_type = @mime_content_type($path);
} }
// fall back to user-submitted string // fall back to user-submitted string
if (!$mime_type) { if (!$mime_type) {

@ -725,8 +725,9 @@ function rcmail_write_compose_attachments(&$message, $bodyIsHtml)
foreach ((array)$message->mime_parts as $pid => $part) foreach ((array)$message->mime_parts as $pid => $part)
{ {
if (($part->ctype_primary != 'message' || !$bodyIsHtml) && $part->ctype_primary != 'multipart' && if (($part->ctype_primary != 'message' || !$bodyIsHtml) && $part->ctype_primary != 'multipart' &&
($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename)) ($part->disposition == 'attachment' || ($part->disposition == 'inline' && $bodyIsHtml) || $part->filename)
{ && $part->mimetype != 'application/ms-tnef'
) {
$skip = false; $skip = false;
if ($part->mimetype == 'message/rfc822') { if ($part->mimetype == 'message/rfc822') {
$messages[] = $part->mime_id; $messages[] = $part->mime_id;

@ -50,15 +50,6 @@ if (!empty($_GET['_frame'])) {
} }
else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) { else if ($pid = get_input_value('_part', RCUBE_INPUT_GET)) {
// TNEF encoded attachment part
if (preg_match('/^winmail\.([0-9.]+)\.([0-9]+)$/', $pid, $nt)) {
$pid = $nt[1]; $i = $nt[2];
if ($part = $MESSAGE->mime_parts[$pid]) {
$tnef_arr = $IMAP->tnef_decode($part, $MESSAGE->uid);
if (is_a($tnef_arr[$i], 'rcube_message_part'))
$MESSAGE->mime_parts[$pid] = $tnef_arr[$i];
}
}
if ($part = $MESSAGE->mime_parts[$pid]) { if ($part = $MESSAGE->mime_parts[$pid]) {
$ctype_primary = strtolower($part->ctype_primary); $ctype_primary = strtolower($part->ctype_primary);

Loading…
Cancel
Save