Use charset from email when displaying and replying
authorJamie Cameron <jcameron@webmin.com>
Thu, 26 Mar 2009 18:38:47 +0000 (18:38 +0000)
committerJamie Cameron <jcameron@webmin.com>
Thu, 26 Mar 2009 18:38:47 +0000 (18:38 +0000)
mailboxes/CHANGELOG
mailboxes/reply_mail.cgi
mailboxes/send_mail.cgi
mailboxes/view_mail.cgi

index 486a30e..e045eed 100644 (file)
@@ -58,3 +58,6 @@ Re-wrote the entire user interface to use the new Webmin UI library, and to brin
 HTML messages now have a converted plain-text attachment automatically added, for mail clients that only support text.
 ---- Changes since 1.450 ----
 Added Module Config options to not include the X-Mailer and X-Originating-IP headers in sent mail.
+---- Changes since 1.470 ----
+When replying to a message, the original character set is used. Also, a bug that prevented the character set from being displayed when viewing a message is fixed.
+Messages with alternate HTML and text bodies are now send with the multipart/alternative content type, which fixes the problem of Gmail showing the body twice.
index 7096a35..0ebe46e 100755 (executable)
@@ -53,6 +53,11 @@ else {
        &check_modification($folder) if ($in{'delete'});
        $mail || &error($text{'mail_eexists'});
 
+       # Find the body parts and set the character set
+       ($textbody, $htmlbody, $body) =
+               &find_body($mail, $config{'view_html'});
+       $main::force_charset = &get_mail_charset($mail, $body);
+
        if ($in{'delete'}) {
                # Just delete the email
                if (!$in{'confirm'} && &need_delete_warn($folder)) {
@@ -87,8 +92,6 @@ else {
        elsif ($in{'print'}) {
                # Show email for printing
                &decode_and_sub();
-               ($textbody, $htmlbody, $body) =
-                       &find_body($mail, $config{'view_html'});
                 &ui_print_header(undef, &decode_mimewords(
                                         $mail->{'header'}->{'subject'}));
                 &show_mail_printable($mail, $body, $textbody, $htmlbody);
@@ -339,6 +342,7 @@ print &ui_hidden("enew", $in{'enew'});
 foreach $s (@sub) {
        print &ui_hidden("sub", $s);
        }
+print &ui_hidden("charset", $main::force_charset);
 
 # Start tabs for from / to / cc / bcc
 # Subject is separate
index 5b9a990..288497e 100755 (executable)
@@ -76,6 +76,9 @@ if ($in{'body'} =~ /\S/) {
                        }
                }
        local $mt = $in{'html_edit'} ? "text/html" : "text/plain";
+       if ($in{'charset'}) {
+               $mt .= "; charset=$in{'charset'}";
+               }
        if ($in{'body'} =~ /[\177-\377]/) {
                # Contains 8-bit characters .. need to make quoted-printable
                $quoted_printable++;
index c111f1d..be719eb 100755 (executable)
@@ -3,7 +3,6 @@
 # View a single email message 
 
 require './mailboxes-lib.pl';
-$main::force_charset = '';
 &ReadParse();
 &can_user($in{'user'}) || &error($text{'mail_ecannot'});
 if (&is_user($in{'user'})) {
@@ -62,6 +61,9 @@ if ($body && $body eq $htmlbody) {
        $headstuff = &head_html($body->{'data'});
        }
 
+# Set the character set for the page to match email
+$main::force_charset = &get_mail_charset($mail, $body);
+
 &mail_page_header($text{'view_title'}, $headstuff, undef,
                  &folder_link($in{'user'}, $folder));
 print &check_clicks_function();