Reinserting support for the "iframe_height" option. This might be done in a better...
[squirrelmail.git] / functions / mime.php
index 11c9f4cfaad3a37e3fe30987624a6becd2e83213..c151ecf6f5cb2d6d30c52a7426fad33f3827ccc0 100644 (file)
@@ -60,12 +60,11 @@ function mime_structure ($bodystructure, $flags=array()) {
 
     if (!is_object($msg)) {
         global $color, $mailbox;
-        /* removed urldecode because $_GET is auto urldecoded ??? */
         displayPageHeader( $color, $mailbox );
         $errormessage  = _("SquirrelMail could not decode the bodystructure of the message");
         $errormessage .= '<br />'._("The bodystructure provided by your IMAP server:").'<br /><br />';
         $errormessage .= '<pre>' . htmlspecialchars($read) . '</pre>';
-        plain_error_message( $errormessage, $color );
+        plain_error_message( $errormessage );
         echo '</body></html>';
         exit;
     }
@@ -148,6 +147,8 @@ function mime_fetch_body($imap_stream, $id, $ent_id=1, $fetch_size=0) {
 //        }
     } else if (ereg('"([^"]*)"', $topline, $regs)) {
         $ret = $regs[1];
+    } else if ((stristr($topline, 'nil') !== false) && (empty($wholemessage))) {
+        $ret = $wholemessage;
     } else {
         global $where, $what, $mailbox, $passed_id, $startMessage;
         $par = 'mailbox=' . urlencode($mailbox) . '&amp;passed_id=' . $passed_id;
@@ -353,9 +354,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
            $show_html_default, $sort, $has_unsafe_images, $passed_ent_id,
            $use_iframe, $iframe_height, $download_and_unsafe_link,
            $download_href, $unsafe_image_toggle_href, $unsafe_image_toggle_text,
-           $oTemplate;
-
-    $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
+           $oTemplate, $nbsp;
 
     // workaround for not updated config.php
     if (! isset($use_iframe)) $use_iframe = false;
@@ -422,6 +421,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
 
                 global $oTemplate;
                 $oTemplate->assign('iframe_url', $iframeurl);
+                $oTemplate->assign('iframe_height', $iframe_height);
                 $oTemplate->assign('html_body', $html_body);
 
                 $body = $oTemplate->fetch('read_html_iframe.tpl');
@@ -562,32 +562,41 @@ function buildAttachmentArray($message, $exclude_id, $mailbox, $id) {
          * for a more generic type. Finally, a hook for ALL attachment
          * types is run as well.
          */
+        // First remember the default link.
+        $defaultlink_orig = $defaultlink;
+
         /* The API for this hook has changed as of 1.5.2 so that all plugin
            arguments are passed in an array instead of each their own plugin
            argument, and arguments are passed by reference, so instead of
            returning any changes, changes should simply be made to the original
            arguments themselves. */
-        do_hook("attachment $type0/$type1", $temp=array(&$links,
-                &$startMessage, &$id, &$urlMailbox, &$ent, &$defaultlink,
-                &$display_filename, &$where, &$what));
-        if(count($links) <= 1) {
+        $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
+                    &$defaultlink, &$display_filename, &$where, &$what);
+        do_hook("attachment $type0/$type1", $temp);
+        if(count($links) <= 1 && $defaultlink == $defaultlink_orig) {
             /* The API for this hook has changed as of 1.5.2 so that all plugin
                arguments are passed in an array instead of each their own plugin
                argument, and arguments are passed by reference, so instead of
                returning any changes, changes should simply be made to the original
                arguments themselves. */
-            do_hook("attachment $type0/*", $temp=array(&$links,
-                    &$startMessage, &$id, &$urlMailbox, &$ent, &$defaultlink,
-                    &$display_filename, &$where, &$what));
+            $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
+                          &$defaultlink, &$display_filename, &$where, &$what);
+            do_hook("attachment $type0/*", $temp);
         }
         /* The API for this hook has changed as of 1.5.2 so that all plugin
            arguments are passed in an array instead of each their own plugin
            argument, and arguments are passed by reference, so instead of
            returning any changes, changes should simply be made to the original
            arguments themselves. */
-        do_hook("attachment */*", $temp=array(&$links,
-                &$startMessage, &$id, &$urlMailbox, &$ent, &$defaultlink, 
-                &$display_filename, &$where, &$what));
+        $temp = array(&$links, &$startMessage, &$id, &$urlMailbox, &$ent, 
+                      &$defaultlink, &$display_filename, &$where, &$what);
+        // Do not let a generic plugin change the default link if a more
+        // specialized one already did it...
+        if ($defaultlink != $defaultlink_orig) {
+            $dummy = '';
+            $temp[5] = &$dummy;
+        }
+        do_hook("attachment */*", $temp);
 
         $this_attachment = array();
         $this_attachment['Name'] = decodeHeader($display_filename);
@@ -1848,6 +1857,7 @@ function sq_fix_url($attname, &$attvalue, $message, $id, $mailbox,$sQuote = '"')
             $aUrl = parse_url($attvalue);
             if (isset($aUrl['scheme'])) {
                 switch(strtolower($aUrl['scheme'])) {
+                    case 'mailto':
                     case 'http':
                     case 'https':
                     case 'ftp':
@@ -1906,7 +1916,6 @@ function sq_fix_url($attname, &$attvalue, $message, $id, $mailbox,$sQuote = '"')
  * @return           a string with edited content.
  */
 function sq_fixstyle($body, $pos, $message, $id, $mailbox){
-    global $view_unsafe_images;
     $me = 'sq_fixstyle';
     // workaround for </style> in between comments
     $iCurrentPos = $pos;