Re-add limit_inline_size.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 21 Nov 2008 08:01:59 +0000 (01:01 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 21 Nov 2008 08:01:59 +0000 (01:01 -0700)
Add a limit for HTML messages also.

imp/config/mime_drivers.php.dist
imp/lib/Contents.php

index 04a68ea..2082cbd 100644 (file)
@@ -57,7 +57,9 @@ $mime_drivers_map['imp']['overrides'] = array();
  */
 $mime_drivers['imp']['plain'] = array(
     'inline' => true,
-    'handles' => array('text/plain', 'text/rfc822-headers', 'application/pgp'),
+    'handles' => array(
+        'text/plain', 'text/rfc822-headers', 'application/pgp'
+    ),
     /* 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.
@@ -82,6 +84,11 @@ $mime_drivers['imp']['html'] = array(
     'icons' => array(
         'default' => 'html.png'
     ),
+    /* 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.
+     * Set to 0 to disable this check. */
+    'limit_inline_size' => 1048576,
     /* Run 'tidy' on all HTML output? This requires at least version 2.0 of the
      * PECL 'tidy' extension to be installed on your system. */
     'tidy' => false,
index f7f541e..48b75b9 100644 (file)
@@ -326,6 +326,24 @@ class IMP_Contents
         case self::RENDER_INLINE_AUTO:
         case self::RENDER_INLINE_DISP_NO:
             $textmode = 'inline';
+            $limit = $viewer->getConfigParam('limit_inline_size');
+            if ($limit && ($mime_part->getBytes() > $limit)) {
+                return array(
+                    $mime_id => array(
+                        'data' => '',
+                        'name' => '',
+                        'status' => array(
+                            array(
+                                'text' => array(
+                                    _("This message part cannot be viewed because it is too large."),
+                                    sprintf(_("Click %s to download the data."), $this->linkView($mime_part, 'download_attach', _("HERE")))
+                                )
+                            )
+                        ),
+                        'type' => 'text/html; charset=' . NLS::getCharset()
+                    )
+                );
+            }
             break;
 
         case self::RENDER_INFO: