adding limit_scope and filter support. Should close #1035454 and #539534
[squirrelmail.git] / src / download.php
index fa966ed4106a5058c913d059658e3ac5a0a28d82..de1c449c7e2bf4d419d534fcba2a30f3f0ca2e61 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * download.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.
  *
  * Handles attachment downloads to the users computer.
@@ -40,6 +40,9 @@ if ( sqgetGlobalVar('passed_id', $temp, SQ_GET) ) {
     $passed_id = (int) $temp;
 }
 
+global $default_charset;
+set_my_charset();
+
 /* end globals */
 
 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
@@ -105,11 +108,13 @@ 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
+$filename = decodeHeader($filename,true,false);
+$filename = charset_encode($filename,$default_charset,false);
+
+// If name is not set, use subject of email
 if (strlen($filename) < 1) {
-    //$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
+    $filename = decodeHeader($subject, true, true);
+    $filename = charset_encode($filename,$default_charset,false);
     if ($type1 == 'plain' && $type0 == 'text')
         $suffix = 'txt';
     else if ($type1 == 'richtext' && $type0 == 'text')
@@ -138,7 +143,7 @@ if (strlen($filename) < 1) {
  *    most likely display the attachment inline inside the browser.
  *      And finally, the third one will be used by default.  If it
  *    is displayable (text or html), it will load them up in a text
- *    viewer (built in to squirrelmail).  Otherwise, it sets the
+ *    viewer (built in to SquirrelMail).  Otherwise, it sets the
  *    content-type as application/octet-stream
  */
 if (isset($absolute_dl) && $absolute_dl) {
@@ -151,4 +156,4 @@ if (isset($absolute_dl) && $absolute_dl) {
 mime_print_body_lines ($imapConnection, $passed_id, $ent_id, $encoding);
 $mailbox_cache[$aMailbox['NAME']] = $aMailbox;
 sqsession_register($mailbox_cache,'mailbox_cache');
-?>
+?>
\ No newline at end of file