From 743e5e5ab1217f3399a9b4230ebd5e6e60513ee1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sun, 9 Nov 2008 23:43:45 -0700 Subject: [PATCH] Remove uuencode handling. --- imp/config/mime_drivers.php.dist | 5 ----- imp/lib/MIME/Viewer/html.php | 36 ++++++++++++++++++++++-------------- imp/lib/MIME/Viewer/plain.php | 39 +++++++++++++-------------------------- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/imp/config/mime_drivers.php.dist b/imp/config/mime_drivers.php.dist index 01e03c0ca..923986834 100644 --- a/imp/config/mime_drivers.php.dist +++ b/imp/config/mime_drivers.php.dist @@ -58,11 +58,6 @@ $mime_drivers_map['imp']['overrides'] = array(); $mime_drivers['imp']['plain'] = array( 'inline' => true, 'handles' => array('text/plain', 'text/rfc822-headers', 'application/pgp'), - /* If you want to scan ALL incoming messages for UUencoded data, set the - * following to true. This is very performance intensive and can take a - * long time for large messages. It is not recommended and is disabled by - * default. */ - 'uuencode' => false, /* If you want to limit the display of message data inline for large * messages, set the maximum size of the displayed message here (in * bytes). If exceeded, the user will only be able to download the part. diff --git a/imp/lib/MIME/Viewer/html.php b/imp/lib/MIME/Viewer/html.php index 9a679a544..ea8d4b52a 100644 --- a/imp/lib/MIME/Viewer/html.php +++ b/imp/lib/MIME/Viewer/html.php @@ -69,8 +69,11 @@ class IMP_Horde_MIME_Viewer_html extends Horde_MIME_Viewer_html */ protected function _render() { + $render = $this->_IMPrender(false); + return array( - 'data' => $this->_IMPrender(false), + 'data' => $render['html'], + 'status' => $render['status'], 'type' => $this->_mimepart->getType(true) ); } @@ -80,7 +83,12 @@ class IMP_Horde_MIME_Viewer_html extends Horde_MIME_Viewer_html */ protected function _renderInline() { - return $this->_IMPrender(true); + $render = $this->_IMPrender(true); + + return array( + 'data' => $render['html'], + 'status' => $render['status'] + ); } /** @@ -88,7 +96,7 @@ class IMP_Horde_MIME_Viewer_html extends Horde_MIME_Viewer_html * * @param boolean $inline Are we viewing inline? * - * @return string The rendered text in HTML. + * @return array Two elements: html and status. */ protected function _IMPrender($inline) { @@ -116,7 +124,8 @@ class IMP_Horde_MIME_Viewer_html extends Horde_MIME_Viewer_html } /* Sanitize the HTML. */ - $data = $this->_cleanHTML($data, $inline); + $cleanhtml = $this->_cleanHTML($data, $inline); + $data = $cleanhtml['html']; /* Reset absolutely positioned elements. */ if ($inline) { @@ -203,17 +212,16 @@ class IMP_Horde_MIME_Viewer_html extends Horde_MIME_Viewer_html /* If we are viewing inline, give option to view in separate window. */ if ($inline && $this->getConfigParam('external')) { - if ($msg) { - $msg = str_replace('', ' | ', $msg); - } - $msg .= $this->_params['contents']->linkViewJS($this->mime_part, 'view_attach', _("Show this HTML in a new window?")); + $cleanhtml['status'][] = array( + 'data' => $this->_params['contents']->linkViewJS($this->mime_part, 'view_attach', _("Show this HTML in a new window?")), + 'type' => 'info' + ); } - $msg = $this->formatStatusMsg($msg, null, false); - - return (stristr($data, ')/is', '$1' . $script . $msg, $data); + return array( + 'html' => $data, + 'status' => $cleanhtml['status'] + ); } /** @@ -221,7 +229,7 @@ class IMP_Horde_MIME_Viewer_html extends Horde_MIME_Viewer_html */ protected function _mailtoCallback($m) { - return 'href="' . $GLOBALS['registry']->call('mail/compose', array(String::convertCharset(html_entity_decode($m[2]), 'iso-8859-1', NLS::getCharset()))) . '"'; + return 'href="' . $GLOBALS['registry']->call('mail/compose', array(String::convertCharset(html_entity_decode($m[2]), 'ISO-8859-1', NLS::getCharset()))) . '"'; } /** diff --git a/imp/lib/MIME/Viewer/plain.php b/imp/lib/MIME/Viewer/plain.php index 886467b8c..96aae6c90 100644 --- a/imp/lib/MIME/Viewer/plain.php +++ b/imp/lib/MIME/Viewer/plain.php @@ -26,7 +26,10 @@ class IMP_Horde_MIME_Viewer_plain extends Horde_MIME_Viewer_plain // Trim extra whitespace in the text. $text = rtrim($this->_mimepart->getContents()); if ($text == '') { - return ''; + return array( + 'data' => '', + 'status' => array() + ); } // If requested, scan the message for PGP data. @@ -36,18 +39,13 @@ class IMP_Horde_MIME_Viewer_plain extends Horde_MIME_Viewer_plain require_once IMP_BASE . '/lib/Crypt/PGP.php'; $imp_pgp = new IMP_PGP(); if (($out = $imp_pgp->parseMessageOutput($this->_mimepart, $this->_params['contents']))) { - return $out; + return array( + 'data' => $out, + 'status' => array() + ); } } - // If requested, scan the message for UUencoded data. - if ($this->getConfigParam('uuencode')) { - // Don't want to use convert_uudecode() here as there may be - // multiple files residing in the text. - require_once 'Mail/mimeDecode.php'; - $files = &Mail_mimeDecode::uudecode($text); - } - // Check for 'flowed' text data. if ($this->_mimepart->getContentTypeParameter('format') == 'flowed') { $text = $this->_formatFlowed($text, $this->_mimepart->getContentTypeParameter('delsp')); @@ -61,6 +59,7 @@ class IMP_Horde_MIME_Viewer_plain extends Horde_MIME_Viewer_plain } // Build filter stack. Starts with HTML markup and tab expansion. + require_once 'Horde/Text/Filter.php'; $filters = array( 'text2html' => array( 'parselevel' => TEXT_HTML_MICRO, @@ -102,7 +101,6 @@ class IMP_Horde_MIME_Viewer_plain extends Horde_MIME_Viewer_plain } // Run filters. - require_once 'Horde/Text/Filter.php'; $text = Text_Filter::filter($text, array_keys($filters), array_values($filters)); // Wordwrap. @@ -110,21 +108,10 @@ class IMP_Horde_MIME_Viewer_plain extends Horde_MIME_Viewer_plain if (!strncmp($text, ' ', 1)) { $text = ' ' . substr($text, 1); } - $text = '
' . "\n" . $text . '
'; - // Replace UUencoded data with links now. - if ($this->getConfigParam('uuencode') && !empty($files)) { - foreach ($files as $file) { - $uupart = new Horde_MIME_Part(); - $uupart->setContents($file['filedata']); - $uupart->setName(strip_tags($file['filename'])); - - $uumessage = Horde_MIME_Message::convertMIMEPart($uupart); - $mc = new IMP_Contents($uumessage); - //$text = preg_replace("/begin ([0-7]{3}) (.+)\r?\n(.+)\r?\nend/Us", '' . $mc->getMessage(true) . '
', $text, 1); - } - } - - return $text; + return array( + 'data' => '
' . "\n" . $text . '
', + 'status' => array() + ); } } -- 2.11.0