Remove uuencode handling.
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 10 Nov 2008 06:43:45 +0000 (23:43 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 10 Nov 2008 06:43:45 +0000 (23:43 -0700)
imp/config/mime_drivers.php.dist
imp/lib/MIME/Viewer/html.php
imp/lib/MIME/Viewer/plain.php

index 01e03c0..9239868 100644 (file)
@@ -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.
index 9a679a5..ea8d4b5 100644 (file)
@@ -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('</span>', ' | </span>', $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, '<body') === false)
-            ? $script . $msg . $data
-            : preg_replace('/(<body.*?>)/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()))) . '"';
     }
 
     /**
index 886467b..96aae6c 100644 (file)
@@ -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 = '&nbsp;' . substr($text, 1);
         }
-        $text = '<div class="fixed leftAlign">' . "\n" . $text . '</div>';
 
-        // 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", '<table>' . $mc->getMessage(true) . '</table>', $text, 1);
-            }
-        }
-
-        return $text;
+        return array(
+            'data' => '<div class="fixed leftAlign">' . "\n" . $text . '</div>',
+            'status' => array()
+        );
     }
 }