diff options
Diffstat (limited to '')
-rwxr-xr-x | scripts/w3mmail.cgi.in | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/scripts/w3mmail.cgi.in b/scripts/w3mmail.cgi.in index 1dafac3..9cfe5a0 100755 --- a/scripts/w3mmail.cgi.in +++ b/scripts/w3mmail.cgi.in @@ -1,6 +1,6 @@ #!@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/; ($prog=$0) =~ s/.*\///; @@ -96,15 +96,15 @@ if ($query =~ s/^\w+://) { print "<pre>\n"; foreach $h (keys %opt) { $qh = &html_quote($h); - $v{$h} = &lang_header(&lang_html_quote($opt{$h})); + $v{$h} = &lang_html_quote($opt{$h}); if ($v{$h}) { 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 "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 "\n"; print $body; @@ -115,7 +115,7 @@ if ($query =~ s/^\w+://) { print "<table>\n"; if ($opt{'from'}) { 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'}; } foreach $h ('to', 'cc', 'bcc', 'subject') { @@ -152,7 +152,7 @@ if ($query =~ s/^\w+://) { 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 "Content-Type: text/plain; charset=$cs\n"; print MAIL "Content-Transfer-Encoding: $cte\n"; @@ -175,7 +175,7 @@ if ($query =~ s/^\w+://) { } sub lang_setup { - $lang = $ENV{'LANG'}; + $lang = $ENV{'LC_ALL'} || $ENV{'LC_CTYPE'} || $ENV{'LANG'}; if ($lang =~ /^ja/i) { eval "use NKF;"; if (! $@) { @@ -215,16 +215,21 @@ sub lang_html_quote { sub lang_header_default { local($h) = @_; if ($h =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) { - return "=iso-8859-1?Q?$h?="; + return "=?iso-8859-1?Q?$h?="; } else { return $h; } } sub lang_body_default { - local($body) = @_; - if ($body =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) { - return ("iso-8859-1", "quoted-printable", $body); + local($body, $_7bit) = @_; + if ($body =~ /[\x80-\xFF]/) { + 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 { return ("US-ASCII", "7bit", $body); } @@ -241,9 +246,11 @@ sub lang_header_ja { } sub lang_body_ja { - local($body) = @_; + local($body, $_7bit) = @_; 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); } else { return ("US-ASCII", "7bit", $body); |