From cf9cb953ee59aa2641e5edfa89ef576b48c64f0f Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 15 Dec 2009 00:21:05 -0700 Subject: [PATCH] Ignore TNEF attachments if they contain no files --- imp/lib/Mime/Viewer/Tnef.php | 48 +++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/imp/lib/Mime/Viewer/Tnef.php b/imp/lib/Mime/Viewer/Tnef.php index 7117a044e..039bed745 100644 --- a/imp/lib/Mime/Viewer/Tnef.php +++ b/imp/lib/Mime/Viewer/Tnef.php @@ -86,42 +86,44 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef $tnef = Horde_Compress::factory('tnef'); $tnefData = $tnef->decompress($this->_mimepart->getContents()); - $text = ''; - if (!count($tnefData)) { - $status = array( - 'text' => array(_("No attachments found.")) - ); - } else { - $status = array( - 'text' => array(_("The following files were attached to this part:")) + /* Ignore attachment if it doesn't contain any files. */ + return array( + $this->_mimepart->getMimeId() => null ); + } - reset($tnefData); - while (list($key, $data) = each($tnefData)) { - $temp_part = $this->_mimepart; - $temp_part->setName($data['name']); - $temp_part->setDescription($data['name']); + $text = ''; - /* Short-circuit MIME-type guessing for winmail.dat parts; - * we're showing enough entries for them already. */ - $type = $data['type'] . '/' . $data['subtype']; - if (in_array($type, array('application/octet-stream', 'application/base64'))) { - $type = Horde_Mime_Magic::filenameToMIME($data['name']); - } - $temp_part->setType($type); + reset($tnefData); + while (list($key, $data) = each($tnefData)) { + $temp_part = $this->_mimepart; + $temp_part->setName($data['name']); + $temp_part->setDescription($data['name']); - $link = $this->_params['contents']->linkView($temp_part, 'view_attach', htmlspecialchars($data['name']), array('jstext' => sprintf(_("View %s"), $data['name']), 'params' => array('tnef_attachment' => $key + 1))); - $text .= _("Attached File:") . '  ' . $link . '  (' . $data['type'] . '/' . $data['subtype'] . ")
\n"; + /* Short-circuit MIME-type guessing for winmail.dat parts; + * we're showing enough entries for them already. */ + $type = $data['type'] . '/' . $data['subtype']; + if (in_array($type, array('application/octet-stream', 'application/base64'))) { + $type = Horde_Mime_Magic::filenameToMIME($data['name']); } + $temp_part->setType($type); + + $link = $this->_params['contents']->linkView($temp_part, 'view_attach', htmlspecialchars($data['name']), array('jstext' => sprintf(_("View %s"), $data['name']), 'params' => array('tnef_attachment' => $key + 1))); + $text .= _("Attached File:") . '  ' . $link . '  (' . $data['type'] . '/' . $data['subtype'] . ")
\n"; } return array( $this->_mimepart->getMimeId() => array( 'data' => $text, - 'status' => array($status), + 'status' => array( + array( + 'text' => array(_("The following files were attached to this part:")) + ) + ), 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); } + } -- 2.11.0