ChangeLog
[squirrelmail.git] / src / download.php
index b4f3dc1de4ae7ac7ba9d13d4c4313a28f5358438..5feed3eafcf5871c56b75e7c654d38cdffebca18 100644 (file)
@@ -3,16 +3,17 @@
 /**
  * download.php
  *
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * Handles attachment downloads to the users computer.
  * Also allows displaying of attachments when possible.
  *
  * $Id$
+ * @package squirrelmail
  */
 
-/* Path for SquirrelMail required files. */
+/** Path for SquirrelMail required files. */
 define('SM_PATH','../');
 
 /* SquirrelMail required files. */
@@ -92,29 +93,25 @@ if (is_object($message->header->disposition)) {
     $filename = $header->getParameter('name');
 }
 
+//$filename = decodeHeader($filename, false, false);   //Don't want html output nor utf8 because it will return html output
 $filename = decodeHeader($filename, true, false);   //Don't want html output
 if (strlen($filename) < 1) {
-    if ($type1 == 'plain' && $type0 == 'text') {
+    //$filename = decodeHeader($subject, false, false);        //Don't want html output nor utf8 because it will return html output
+    $filename = decodeHeader($subject, true, false);   //Don't want html output
+    if ($type1 == 'plain' && $type0 == 'text')
         $suffix = 'txt';
-        $filename = $subject . '.txt';
-    } else if ($type1 == 'richtext' && $type0 == 'text') {
+    else if ($type1 == 'richtext' && $type0 == 'text')
         $suffix = 'rtf';
-        $filename = $subject . '.rtf';
-    } else if ($type1 == 'postscript' && $type0 == 'application') {
+    else if ($type1 == 'postscript' && $type0 == 'application')
         $suffix = 'ps';
-        $filename = $subject . '.ps';
-    } else if ($type1 == 'rfc822' && $type0 == 'message') {
-        $suffix = 'eml';
-        $filename = $subject . '.msg';
-    } else {
+    else if ($type1 == 'rfc822' && $type0 == 'message')
+        $suffix = 'msg';
+    else
         $suffix = $type1;
-    }
 
-    if (strlen($filename) < 1) {
-       $filename = 'untitled'.strip_tags($ent_id).'.'.$suffix;
-    } else {
-       $filename = "$filename.$suffix";
-    }
+    if ($filename == '')
+        $filename = 'untitled' . strip_tags($ent_id);
+    $filename = $filename . '.' . $suffix;
 }
 
 /*
@@ -141,4 +138,4 @@ if (isset($absolute_dl) && $absolute_dl) {
  * attachment in case of ERROR reporting = E_ALL and the output is the screen */
 mime_print_body_lines ($imapConnection, $passed_id, $ent_id, $encoding);
 
-?>
\ No newline at end of file
+?>