Cvascript detection was broken when you changed your setting from never
[squirrelmail.git] / functions / mime.php
index ca700c83cfa520a6f814219d9842fa1478b83218..f8eb09b0f2c87be101def705666e22ce2a3b8c7c 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * mime.php
  *
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Copyright (c) 1999-2005 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This contains the functions necessary to detect and decode MIME
@@ -341,9 +341,8 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
      * primary message. To add more of them, just put them in the
      * order that is their priority.
      */
-    global $startMessage, $username, $key, $imapServerAddress, $imapPort,
+    global $startMessage, $languages, $squirrelmail_language,
            $show_html_default, $sort, $has_unsafe_images, $passed_ent_id;
-    global $languages, $squirrelmail_language;
 
     if( !sqgetGlobalVar('view_unsafe_images', $view_unsafe_images, SQ_GET) ) {
         $view_unsafe_images = false;
@@ -421,8 +420,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma
 
 
 function formatAttachments($message, $exclude_id, $mailbox, $id) {
-    global $where, $what, $startMessage, $color;
-    static $ShownHTML = 0;
+    global $where, $what, $startMessage, $color, $passed_ent_id;
 
     $att_ar = $message->getAttachments($exclude_id);
 
@@ -441,7 +439,6 @@ function formatAttachments($message, $exclude_id, $mailbox, $id) {
         $links['download link']['text'] = _("Download");
         $links['download link']['href'] = SM_PATH .
                 "src/download.php?absolute_dl=true&passed_id=$id&mailbox=$urlMailbox&ent_id=$ent";
-        $ImageURL = '';
         if ($type0 =='message' && $type1 == 'rfc822') {
             $default_page = SM_PATH . 'src/read_body.php';
             $rfc822_header = $att->rfc822_header;
@@ -677,14 +674,21 @@ function decodeHeader ($string, $utfencode=true,$htmlsave=true,$decide=false) {
             {
             case 'B':
                 $replace = base64_decode($res[4]);
-                if ($can_be_encoded) {
-                  /* convert string to different charset,
-                   * if functions asks for it (usually in compose)
-                   */
-                  $ret .= charset_convert($res[2],$replace,$default_charset);
+                if ($utfencode) {
+                    if ($can_be_encoded) {
+                        /* convert string to different charset,
+                         * if functions asks for it (usually in compose)
+                         */
+                        $ret .= charset_convert($res[2],$replace,$default_charset);
+                    } else {
+                        // convert string to html codes in order to display it
+                        $ret .= charset_decode($res[2],$replace);
+                    }
                 } else {
-                  // convert string to html codes in order to display it
-                  $ret .= charset_decode($res[2],$replace);
+                    if ($htmlsave) {
+                        $replace = htmlspecialchars($replace);
+                    }
+                    $ret.= $replace;
                 }
                 break;
             case 'Q':
@@ -1120,7 +1124,6 @@ function sq_getnxtag($body, $offset){
             break;
     }
 
-    $tag_start = $pos;
     $tagname = '';
     /**
      * Look for next [\W-_], which will indicate the end of the tag name.
@@ -1180,7 +1183,6 @@ function sq_getnxtag($body, $offset){
      * At this point we loop in order to find all attributes.
      */
     $attname = '';
-    $atttype = false;
     $attary = Array();
 
     while ($pos <= strlen($body)){
@@ -1589,7 +1591,6 @@ function sq_cid2http($message, $id, $cidurl, $mailbox){
 function sq_body2div($attary, $mailbox, $message, $id){
     $me = 'sq_body2div';
     $divattary = Array('class' => "'bodyclass'");
-    $bgcolor = '#ffffff';
     $text = '#000000';
     $has_bgc_stl = $has_txt_stl = false;
     $styledef = '';