[w3m-dev 02926] fixed w3mmail.cgi

* scripts/w3mmail.cgi.in: dont MIME encode for preview
* scripts/w3mmail.cgi.in (lang_body): add 7bit/8bit flag arg
* scripts/w3mmail.cgi.in: fix hidden from value
* scripts/w3mmail.cgi.in (lang_setup): check $LC_ALL, $LC_CTYPE
* scripts/w3mmail.cgi.in (lang_header_default): fix MIME encode word
From: Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-01-29 16:31:09 +00:00
parent 80727e4b02
commit 506e62aae2
2 changed files with 30 additions and 14 deletions

View File

@@ -1,3 +1,12 @@
2002-01-30 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 02926] fixed w3mmail.cgi
* scripts/w3mmail.cgi.in: dont MIME encode for preview
* scripts/w3mmail.cgi.in (lang_body): add 7bit/8bit flag arg
* scripts/w3mmail.cgi.in: fix hidden from value
* scripts/w3mmail.cgi.in (lang_setup): check $LC_ALL, $LC_CTYPE
* scripts/w3mmail.cgi.in (lang_header_default): fix MIME encode word
2002-01-30 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> 2002-01-30 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp>
* [w3m-dev 02920] don't use inttypes.h and/or stdint.h * [w3m-dev 02920] don't use inttypes.h and/or stdint.h
@@ -2346,4 +2355,4 @@
* release-0-2-1 * release-0-2-1
* import w3m-0.2.1 * import w3m-0.2.1
$Id: ChangeLog,v 1.270 2002/01/29 16:23:37 ukai Exp $ $Id: ChangeLog,v 1.271 2002/01/29 16:31:09 ukai Exp $

View File

@@ -1,6 +1,6 @@
#!@PERL@ #!@PERL@
$rcsid = q$Id: w3mmail.cgi.in,v 1.7 2002/01/28 14:44:56 ukai Exp $; $rcsid = q$Id: w3mmail.cgi.in,v 1.8 2002/01/29 16:31:09 ukai Exp $;
($id = $rcsid) =~ s/^.*,v ([\d\.]*).*/$1/; ($id = $rcsid) =~ s/^.*,v ([\d\.]*).*/$1/;
($prog=$0) =~ s/.*\///; ($prog=$0) =~ s/.*\///;
@@ -96,15 +96,15 @@ if ($query =~ s/^\w+://) {
print "<pre>\n"; print "<pre>\n";
foreach $h (keys %opt) { foreach $h (keys %opt) {
$qh = &html_quote($h); $qh = &html_quote($h);
$v{$h} = &lang_header(&lang_html_quote($opt{$h})); $v{$h} = &lang_html_quote($opt{$h});
if ($v{$h}) { if ($v{$h}) {
print "\u$qh: $v{$h}\n"; print "\u$qh: $v{$h}\n";
} }
} }
($cs,$cte,$body) = &lang_body(&lang_html_quote($body)); ($cs,$cte,$body) = &lang_body(&lang_html_quote($body), 0);
print "Mime-Version: 1.0\n"; print "Mime-Version: 1.0\n";
print "Content-Type: text/plain; charset=$cs\n"; print "Content-Type: text/plain; charset=$cs\n";
print "Content-Transfer-Encoding: $cte\n"; # print "Content-Transfer-Encoding: $cte\n";
print "User-Agent: $ENV{'SERVER_SOFTWARE'} $prog/$id\n"; print "User-Agent: $ENV{'SERVER_SOFTWARE'} $prog/$id\n";
print "\n"; print "\n";
print $body; print $body;
@@ -115,7 +115,7 @@ if ($query =~ s/^\w+://) {
print "<table>\n"; print "<table>\n";
if ($opt{'from'}) { if ($opt{'from'}) {
print "<tr><td>From:<td>$v{'from'}\n"; print "<tr><td>From:<td>$v{'from'}\n";
print "<input type='hidden' name='from' value=\"$v\">\n"; print "<input type='hidden' name='from' value=\"$v{'from'}\">\n";
delete $opt{'from'}; delete $opt{'from'};
} }
foreach $h ('to', 'cc', 'bcc', 'subject') { foreach $h ('to', 'cc', 'bcc', 'subject') {
@@ -152,7 +152,7 @@ if ($query =~ s/^\w+://) {
print MAIL "\u$h: $v\n"; print MAIL "\u$h: $v\n";
} }
} }
($cs,$cte,$body) = &lang_body($body); ($cs,$cte,$body) = &lang_body($body, 1);
print MAIL "Mime-Version: 1.0\n"; print MAIL "Mime-Version: 1.0\n";
print MAIL "Content-Type: text/plain; charset=$cs\n"; print MAIL "Content-Type: text/plain; charset=$cs\n";
print MAIL "Content-Transfer-Encoding: $cte\n"; print MAIL "Content-Transfer-Encoding: $cte\n";
@@ -175,7 +175,7 @@ if ($query =~ s/^\w+://) {
} }
sub lang_setup { sub lang_setup {
$lang = $ENV{'LANG'}; $lang = $ENV{'LC_ALL'} || $ENV{'LC_CTYPE'} || $ENV{'LANG'};
if ($lang =~ /^ja/i) { if ($lang =~ /^ja/i) {
eval "use NKF;"; eval "use NKF;";
if (! $@) { if (! $@) {
@@ -215,16 +215,21 @@ sub lang_html_quote {
sub lang_header_default { sub lang_header_default {
local($h) = @_; local($h) = @_;
if ($h =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) { if ($h =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) {
return "=iso-8859-1?Q?$h?="; return "=?iso-8859-1?Q?$h?=";
} else { } else {
return $h; return $h;
} }
} }
sub lang_body_default { sub lang_body_default {
local($body) = @_; local($body, $_7bit) = @_;
if ($body =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) { if ($body =~ /[\x80-\xFF]/) {
return ("iso-8859-1", "quoted-printable", $body); if ($_7bit) {
$body =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge;
return ("iso-8859-1", "quoted-printable", $body);
} else {
return ("iso-8859-1", "8bit", $body);
}
} else { } else {
return ("US-ASCII", "7bit", $body); return ("US-ASCII", "7bit", $body);
} }
@@ -241,9 +246,11 @@ sub lang_header_ja {
} }
sub lang_body_ja { sub lang_body_ja {
local($body) = @_; local($body, $_7bit) = @_;
if ($body =~ /[\x80-\xFF]/ || $body =~ /\033[\$\(][BJ@]/) { if ($body =~ /[\x80-\xFF]/ || $body =~ /\033[\$\(][BJ@]/) {
$body = &conv_nkf("-j", $body); if ($_7bit) {
$body = &conv_nkf("-j", $body);
}
return ("ISO-2022-JP", "7bit", $body); return ("ISO-2022-JP", "7bit", $body);
} else { } else {
return ("US-ASCII", "7bit", $body); return ("US-ASCII", "7bit", $body);