diff --git a/include/class.mailfetch.php b/include/class.mailfetch.php index eaa1ebcdd792afd61c4f252b5c38c2eae660618b..efbe8f2f0511bf1467f547e89bd36a5545bbefd1 100644 --- a/include/class.mailfetch.php +++ b/include/class.mailfetch.php @@ -617,7 +617,7 @@ class MailFetcher { foreach ($this->tnef->attachments as $at) { $attachments[] = array( 'cid' => @$at->AttachContentId ?: false, - 'data' => $at->Data, + 'data' => $at, 'type' => @$at->AttachMimeTag ?: false, 'name' => $at->getName(), ); @@ -631,7 +631,10 @@ class MailFetcher { if(!$ost->isFileTypeAllowed($file)) { $file['error'] = 'Invalid file type (ext) for '.Format::htmlchars($file['name']); } - elseif (!$file['data']) { + elseif (@$a['data'] instanceof TnefAttachment) { + $file['data'] = $a['data']->getData(); + } + else { // only fetch the body if necessary $self = $this; $file['data'] = function() use ($self, $mid, $a) { diff --git a/include/class.mailparse.php b/include/class.mailparse.php index cf4a1269124ebc904a7fd1bb173848fcbcb4e88c..27ea94701fbcb665b26a2a2a96724a13cd517855 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -390,7 +390,7 @@ class Mail_Parse { foreach ($this->tnef->attachments as $at) { $files[] = array( 'cid' => @$at->AttachContentId ?: false, - 'data' => $at->Data, + 'data' => $at->getData(), 'type' => @$at->AttachMimeTag ?: false, 'name' => $at->getName(), ); diff --git a/include/tnef_decoder.php b/include/tnef_decoder.php index 18e95d697c5eba8bb218ff81d5e9c903b2cedbd7..3b8b204a51a86c844458b6a5d120ed3fa550edca 100644 --- a/include/tnef_decoder.php +++ b/include/tnef_decoder.php @@ -209,6 +209,7 @@ class TnefAttribute { const AttributeReadOnly = 0x10f6; const CreationTime = 0x3007; const LastModificationTime = 0x3008; + const AttachDataBinary = 0x3701; const AttachEncoding = 0x3702; const AttachExtension = 0x3703; const AttachFilename = 0x3704; @@ -555,6 +556,13 @@ class TnefAttachment extends AbstractTnefObject { $this->Data = $data; } + function getData() { + if (isset($this->Data)) + return $this->Data; + elseif (isset($this->AttachDataBinary)) + return $this->AttachDataBinary; + } + function _setRenderingData($data) { // Pass }