From 769e60d51f3e7de98cdfcadba617e15fe33e8432 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 19 Jul 2011 10:07:26 +0000 Subject: [PATCH] take care that winmail.dat attachments are only resolved by tnef (if available) if required (e.g.:the message is opened) --- felamimail/inc/class.bofelamimail.inc.php | 16 +++++++++------- felamimail/inc/class.uiwidgets.inc.php | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/felamimail/inc/class.bofelamimail.inc.php b/felamimail/inc/class.bofelamimail.inc.php index 4b93b4ceb6..9c4474a4ea 100644 --- a/felamimail/inc/class.bofelamimail.inc.php +++ b/felamimail/inc/class.bofelamimail.inc.php @@ -480,8 +480,10 @@ function decode_winmail( $_uid, $_partID, $_filenumber=0 ) { $attachment = $this->getAttachment( $_uid, $_partID ); - - $dir = $GLOBALS['egw_info']['server']['temp_dir']."/fmail_winmail/$_uid"; + $dirname = $this->accountid.'_'.$this->profileID.'_'.$this->sessionData['mailbox'].'_'.$_uid.'_'.$_partID; + if (self::$debug) error_log(__METHOD__.__LINE__.' Dirname:'.$dirname); + $dirname = md5($dirname); + $dir = $GLOBALS['egw_info']['server']['temp_dir']."/fmail_winmail/$dirname"; $mime = CreateObject('phpgwapi.mime_magic'); if ( $attachment['type'] == 'APPLICATION/MS-TNEF' && $attachment['filename'] == 'winmail.dat' ) { @@ -2243,7 +2245,7 @@ return $this->mailPreferences; } - function getMessageAttachments($_uid, $_partID='', $_structure='') + function getMessageAttachments($_uid, $_partID='', $_structure='', $resolveTNEF=true) { if (self::$debug) echo __METHOD__."$_uid, $_partID
"; @@ -2275,7 +2277,7 @@ $newAttachment['cid'] = $structure->cid; } # if the new attachment is a winmail.dat, we have to decode that first - if ( $newAttachment['name'] == 'winmail.dat' && + if ( $resolveTNEF && $newAttachment['name'] == 'winmail.dat' && ( $wmattachments = $this->decode_winmail( $_uid, $newAttachment['partID'] ) ) ) { $attachments = array_merge( $attachments, $wmattachments ); @@ -2307,7 +2309,7 @@ { if ($subPart->type == 'MULTIPART' && $subPart->subType == 'ALTERNATIVE') { - $attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart), $attachments); + $attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart, $resolveTNEF), $attachments); } if (!($subPart->type=='TEXT' && $subPart->disposition =='INLINE' && $subPart->filename)) continue; } @@ -2319,7 +2321,7 @@ $subPart->subType == 'SIGNED' || $subPart->subType == 'APPLEDOUBLE')) { - $attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart), $attachments); + $attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart, $resolveTNEF), $attachments); } else { $newAttachment = array(); $newAttachment['name'] = self::getFileNameFromStructure($subPart); @@ -2334,7 +2336,7 @@ $newAttachment['cid'] = $subPart->cid; } # if the new attachment is a winmail.dat, we have to decode that first - if ( $newAttachment['name'] == 'winmail.dat' && + if ( $resolveTNEF && $newAttachment['name'] == 'winmail.dat' && ( $wmattachments = $this->decode_winmail( $_uid, $newAttachment['partID'] ) ) ) { $attachments = array_merge( $attachments, $wmattachments ); diff --git a/felamimail/inc/class.uiwidgets.inc.php b/felamimail/inc/class.uiwidgets.inc.php index 6003dfd572..c08f8183b9 100644 --- a/felamimail/inc/class.uiwidgets.inc.php +++ b/felamimail/inc/class.uiwidgets.inc.php @@ -377,6 +377,18 @@ class uiwidgets substr($header['mimetype'],0,11) == 'application' || substr($header['mimetype'],0,5) == 'audio') { $image = html::image('felamimail','attach'); + if (//$header['mimetype'] != 'multipart/mixed' && + $header['mimetype'] != 'multipart/signed' + ) + { + if ($this->bofelamimail->icServer->_connected != 1) + { + $this->bofelamimail->openConnection(0); // connect to the current server + $this->bofelamimail->reopen($_folderName); + } + $attachments = $this->bofelamimail->getMessageAttachments($header['uid'],'','',$resolveTNEF=false); + if (count($attachments)<1) $image = ' '; + } $this->t->set_var('attachment_image', $image); } else { $this->t->set_var('attachment_image', ' '); @@ -683,6 +695,13 @@ class uiwidgets $image = "link('/index.php',$linkDataAttachments)."', '".$windowName."', this); return false;\" title=\"".$headerData['subject']."\">".$image.""; + if (//$headerData['mimetype'] != 'multipart/mixed' && + $header['mimetype'] != 'multipart/signed' + ) + { + $attachments = $this->bofelamimail->getMessageAttachments($headerData['uid'],'','',$resolveTNEF=false); + if (count($attachments)<1) $image = ' '; + } $windowName = ($_readInNewWindow == 1 ? 'displayMessage' : 'displayMessage_'.$header['uid']); } else {