From 9c21d23e5e78bdc86d63c900f4f4fc4ec5a67a78 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Tue, 15 Jan 2002 17:46:01 +0000 Subject: [w3m-dev 02843] w3mmail.cgi.in update * scripts/w3mmail.cgi.in: add $SENDMAIL_OPT change html From: Hironori Sakamoto --- scripts/w3mmail.cgi.in | 107 +++++++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 43 deletions(-) (limited to 'scripts') diff --git a/scripts/w3mmail.cgi.in b/scripts/w3mmail.cgi.in index fea6194..c79f413 100755 --- a/scripts/w3mmail.cgi.in +++ b/scripts/w3mmail.cgi.in @@ -1,6 +1,6 @@ #!@PERL@ -$rcsid = q$Id: w3mmail.cgi.in,v 1.2 2002/01/15 16:13:39 ukai Exp $; +$rcsid = q$Id: w3mmail.cgi.in,v 1.3 2002/01/15 17:46:01 ukai Exp $; ($id = $rcsid) =~ s/^.*,v ([\d\.]*).*/$1/; ($prog=$0) =~ s/.*\///; @@ -9,6 +9,7 @@ $local_cookie = $ENV{'LOCAL_COOKIE'}; $url = $query; $SENDMAIL = '/usr/lib/sendmail'; $SENDMAIL = '/usr/sbin/sendmail' if -x '/usr/sbin/sendmail'; +$SENDMAIL_OPT = '-oi -t'; $qurl = &html_quote($url); @@ -26,6 +27,7 @@ if ($query =~ s/^\w+://) { $opt{'to'} = join(',', @to); $body = $opt{'body'}; delete $opt{'body'}; + &lang_setup; print "Content-Type: text/html\r\n"; print "w3m-control: END\r\n"; @@ -34,38 +36,33 @@ if ($query =~ s/^\w+://) { print "W3M Mailer: $qurl\n"; print "

W3M Mailer: $qurl

\n"; print "
\n"; - print "\n"; print "\n"; - print "\n"; + print "
\n"; if ($opt{'from'}) { - print "\n"; + $v = &lang_html_quote($opt{'from'}); + print "\n"; + foreach $h ('to', 'cc', 'bcc', 'subject') { + $v = &lang_html_quote($opt{$h}); + print "\n"; + $qh = &html_quote($h); + $v = &lang_html_quote($opt{$h}); + print "
From:" . &html_quote($opt{'from'}) - . "
From:$v\n"; + print "\n"; delete $opt{'from'}; } - foreach $h ('to', 'cc', 'subject') { - print "
\u$h:"; - if ($opt{$h}) { - print &html_quote($opt{$h}); - print ""; - } else { - print ""; - } - print "
\u$h:\n"; delete $opt{$h}; } foreach $h (keys %opt) { - $h = &html_quote($h); - $v = &html_quote($opt{$h}); - print "
$h$v
\u$h:$v\n"; + print "\n"; } - print "
\n"; print "
\n"; + print "\n"; print "
\n"; print "\n"; exit(0); @@ -79,51 +76,68 @@ if ($query =~ s/^\w+://) { exit 1; } delete $opt{'cookie'}; - $body = &html_quote($opt{'body'}); + $body = $opt{'body'}; delete $opt{'body'}; $act = $opt{'action'}; delete $opt{'action'}; &lang_setup; - if ($act eq "preview") { + if ($act eq "Preview") { print "Content-Type: text/html\r\n"; + print "w3m-control: DELETE_PREVBUF\r\n"; print "w3m-control: NEXT_LINK\r\n"; print "\r\n"; print "W3M Mailer\n"; print "\n"; print "

W3M Mailer: preview

\n"; print "
\n"; - print "\n"; print "\n"; print "
\n"; print "
\n";
 	foreach $h (keys %opt) {
-	    $v = &html_quote(&lang_header($opt{$h}));
-	    if ($v) {
-		print "\u$h: $v\n";
+	    $qh = &html_quote($h);
+	    $v{$h} = &lang_header(&lang_html_quote($opt{$h}));
+	    if ($v{$h}) {
+		print "\u$qh: $v{$h}\n";
 	    }
 	}
-	($cs,$cte,$body) = &lang_body($body);
+	($cs,$cte,$body) = &lang_body(&lang_html_quote($body));
 	print "Mime-Version: 1.0\n";
 	print "Content-Type: text/plain; charset=$cs\n";
 	print "Content-Transfer-Encoding: $cte\n";
 	print "User-Agent: $ENV{'SERVER_SOFTWARE'} $prog/$id\n";
 	print "\n";
 	print $body;
+	print "\n";
 	print "
\n"; + print "\n"; print "
\n"; + print "\n"; + if ($opt{'from'}) { + print "
From:$v{'from'}\n"; + print "\n"; + delete $opt{'from'}; + } + foreach $h ('to', 'cc', 'bcc', 'subject') { + print "
\u$h:\n"; + delete $opt{$h}; + } foreach $h (keys %opt) { - $v = &html_quote($opt{$h}); - if ($v) { - print "\n"; - } + $qh = &html_quote($h); + print "
\u$qh:$v{$h}\n"; + print "\n"; } - print "\n"; - print "\n"; - # print "
\n"; foreach (keys %ENV) { print "$_=$ENV{$_}\n"; } print "
\n"; + print "
\n"; + print "\n"; + print "
\n"; + print "
\n"; print "\n"; } else { - unless (open(MAIL, "|$SENDMAIL -t")) { + unless (open(MAIL, "|$SENDMAIL $SENDMAIL_OPT")) { print "Content-Type: text/html\r\n"; print "\r\n"; print "W3M Mailer\n"; @@ -146,8 +160,7 @@ if ($query =~ s/^\w+://) { print MAIL "\n"; print MAIL $body; if (close(MAIL)) { - print "w3m-control: BACK\r\n"; - print "w3m-control: BACK\r\n"; + print "w3m-control: DELETE_PREVBUF\r\n"; print "w3m-control: BACK\r\n"; print "\r\n"; } else { @@ -189,6 +202,16 @@ sub lang_body { } } +sub lang_html_quote { + local($_) = @_; + if ($lang =~ /^ja/i) { + if (/[\x80-\xFF]/ || /\033[\$\(][BJ@]/) { + $_ = &conv_nkf("-e", $_); + } + } + return &html_quote($_); +} + sub lang_header_default { local($h) = @_; if ($h =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) { @@ -200,7 +223,6 @@ sub lang_header_default { sub lang_body_default { local($body) = @_; - print "default:$body\n"; if ($body =~ s/([\x80-\xFF])/sprintf("=%02x", ord($1))/ge) { return ("iso-8859-1", "quoted-printable", $body); } else { @@ -211,6 +233,7 @@ sub lang_body_default { sub lang_header_ja { local($h) = @_; if ($h =~ /[\x80-\xFF]/ || $h =~ /\033[\$\(][BJ@]/) { + $h = &conv_nkf("-j", $h); &conv_nkf("-M", $h); } else { return $h; @@ -219,11 +242,9 @@ sub lang_header_ja { sub lang_body_ja { local($body) = @_; - if ($body =~ /[\x80-\xFF]/) { + if ($body =~ /[\x80-\xFF]/ || $body =~ /\033[\$\(][BJ@]/) { $body = &conv_nkf("-j", $body); return ("ISO-2022-JP", "7bit", $body); - } elsif ($body =~ /\033[\$\(][BJ@]/) { - return ("ISO-2022-JP", "7bit", $body); } else { return ("US-ASCII", "7bit", $body); } -- cgit v1.2.3