From c4809aca46331814d0ebfe115c2f7ce427f519d1 Mon Sep 17 00:00:00 2001 From: lkehresman Date: Fri, 30 Jun 2000 15:17:20 +0000 Subject: [PATCH] Made some changes to the way that attachments are downloaded -- changed the content-type to "application/octet-stream" so that it will always get downloaded. If it is an image, it has a "view" button beside it for convenience, and that will load the picture in the browser. Updated the configuration script, and documentation on mime git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@574 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- ChangeLog | 1 + config/conf.pl | 37 ++++++++++++++++++++++++++++++------- doc/mime.txt | 10 +++++----- functions/mime.php | 6 ++++++ src/download.php | 29 +++++++++++++++++++++++++---- 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d1f2781..be94954a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ Version 0.5pre1 -- DEVELOPMENT ------------------------------ +- Changed how attachments are displayed and handled - Rewrote MIME support from scratch, optomizing it an unbelievable amount - Added support for message highlighting - Moved Address and Send buttons on Compose form for easier access diff --git a/config/conf.pl b/config/conf.pl index 4436710d..6f917872 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl # conf.pl -# Written March 26, 2000 # Luke Ehresman (luke@squirrelmail.org) # # A simple configure script to configure squirrelmail @@ -36,7 +35,7 @@ while ($line = ) { @options = split(/\s*=\s*/, $var); $options[1] =~ s/[\n|\r]//g; $options[1] =~ s/^"//g; - $options[1] =~ s/;.*$//g; + $options[1] =~ s/;\s*$//g; $options[1] =~ s/"$//g; if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) { @@ -273,7 +272,7 @@ while (($command ne "q") && ($command ne "Q")) { if ($command == 1) { command61(); } elsif ($command == 2) { command62(); } } elsif ($menu == 7) { - if ($command == 1) { $motd = command71 (); $motd =~ s/"/\\"/g;} + if ($command == 1) { $motd = command71(); } } } } @@ -463,12 +462,17 @@ sub command71 { print "\nYou can now create the welcome message that is displayed\n"; print "every time a user logs on. You can use HTML or just plain\n"; print "text.\n\n(Type @ on a blank line to exit)\n"; + do { print "] "; $line = ; $line =~ s/[\r|\n]//g; - $line =~ s/ /\ \ /g; if ($line ne "@") { + $line =~ s/ /\ \ /g; + $line =~ s/\t/\ \ \ \ /g; + $line =~ s/$/ /; + $line =~ s/"/\"/g; + $new_motd = $new_motd . $line; } } while ($line ne "@"); @@ -1107,7 +1111,7 @@ sub command62 { $default_use_javascript_addr_book = "false"; $default_value = "n"; } - print "Use javascript version (y/n) [$WHT$default_value$NRM]: $WHT"; + print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT"; $new_show = ; if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { $default_use_javascript_addr_book = "true"; @@ -1223,8 +1227,9 @@ sub set_defaults { $server = ; $server =~ s/[\r|\n]//g; - if ($server eq "cyrus") { - $default_folder_prefix = ""; + print "\n"; + if ($server eq "cyrus") { + $default_folder_prefix = "INBOX"; $trash_folder = "INBOX.Trash"; $sent_folder = "INBOX.Sent"; $show_prefix_option = false; @@ -1232,6 +1237,14 @@ sub set_defaults { $show_contain_subfolders_option = false; $imap_server_type = "cyrus"; + print " default_folder_prefix = INBOX\n"; + print " trash_folder = INBOX.Trash\n"; + print " sent_folder = INBOX.Sent\n"; + print " show_prefix_optin = false\n"; + print " default_sub_of_inbox = true\n"; + print "show_contain_subfolders_option = false\n"; + print " imap_server_type = cyrus\n"; + $continue = 1; } elsif ($server eq "uw") { $default_folder_prefix = "mail/"; @@ -1241,6 +1254,14 @@ sub set_defaults { $default_sub_of_inbox = false; $show_contain_subfolders_option = true; $imap_server_type = "uw"; + + print " default_folder_prefix = mail/\n"; + print " trash_folder = Trash\n"; + print " sent_folder = Sent\n"; + print " show_prefix_option = true\n"; + print " default_sub_of_inbox = false\n"; + print "show_contain_subfolders_option = true\n"; + print " imap_server_type = uw\n"; $continue = 1; } elsif ($server eq "exchange") { @@ -1265,4 +1286,6 @@ sub set_defaults { print "\n"; } } + print "\nPress any key to continue..."; + $tmp = ; } diff --git a/doc/mime.txt b/doc/mime.txt index 7def8e7f..1636119c 100644 --- a/doc/mime.txt +++ b/doc/mime.txt @@ -3,14 +3,14 @@ by Luke Ehresman June 22, 2000 - Last updated: June 22, 2000 Who should read this? - +--------------------- The intended audience for this document are people who want to understand how the MIME code works. This is a technical documentation of how mime.php works and how it parses a MIME encoded message. Object Structure - +---------------- There are two objects that are used: "message" and "msg_header". here is a brief overview of what each object contains. @@ -43,7 +43,7 @@ Object Structure Getting the Structure - +--------------------- Previously (version 0.4 and below), SquirrelMail handled all the parsing of the email message. It would read the entire message in, search for boundaries, and created an array similar to the $message object discribed @@ -80,7 +80,7 @@ Getting the Structure ftp://ftp.lysator.liu.se/mirror/unix/imapd/mime/torture-test.mbox Getting the Body - +---------------- Once all of the structure of the message has been read into the $message object, we then need to display the body of one entity. There are a number of ways we decide which entity to display at a certain time, and I won't go @@ -98,7 +98,7 @@ Getting the Body Closing Notes - +------------- That is basically how it works. There is a variable in mime.php called $debug_mime that is defined at the top of that file. If you set it to true, it will output all kinds of valuable information while it tries to decode diff --git a/functions/mime.php b/functions/mime.php index 51a7c7b9..cd647bc7 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -477,6 +477,12 @@ $body .= "   " . $display_filename . "  (TYPE: $type0/$type1)"; if ($message->header->description) $body .= "  " . htmlspecialchars($message->header->description).""; + if ($message->header->type0 == "image" && + ($message->header->type1 == "jpg" || + $message->header->type1 == "jpeg" || + $message->header->type1 == "gif" || + $message->header->type1 == "png")) + $body .= " ("._("view").")\n"; $body .= "
"; $num++; } diff --git a/src/download.php b/src/download.php index 884929fe..fa61287c 100644 --- a/src/download.php +++ b/src/download.php @@ -56,24 +56,45 @@ $filename = $header->filename; if (strlen($filename) < 1) { - $filename = "untitled$passed_ent_id"; + $filename = "untitled$passed_ent_id.$type1"; } + // Note: + // The following sections display the attachment in different + // ways depending on how they choose. The first way will download + // under any circumstance. This sets the Content-type to be + // applicatin/octet-stream, which should be interpreted by the + // browser as "download me". + // The second method (view) is used for images or other formats + // that should be able to be handled by the browser. It will + // 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 + // content-type as application/octet-stream + if ($absolute_dl == "true") { switch($type0) { case "text": $body = decodeBody($body, $header->encoding); - header("Content-type: $type0/$type1; name=\"$filename\""); + #header("Content-type: $type0/$type1; name=\"$filename\""); + header("Content-type: application/octet-stream; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); echo trim($body); break; default: $body = decodeBody($body, $header->encoding); - header("Content-type: $type0/$type1; name=\"$filename\""); + header("Content-type: application/octet-stream; name=\"$filename\""); + #header("Content-type: $type0/$type1; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); echo $body; break; } + } else if ($view == "true") { + $body = decodeBody ($body, $header->encoding); + header("Content-type: $type0/$type1; name=\"$filename\""); + header("Content-disposition: attachment; filename=\"$filename\""); + echo $body; } else { switch ($type0) { case "text": @@ -86,7 +107,7 @@ break; default: $body = decodeBody($body, $header->encoding); - header("Content-type: $type0/$type1; name=\"$filename\""); + header("Content-type: applicatin/octet-stream; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); echo $body; break; -- 2.25.1