]> diplodocus.org Git - nmh/blobdiff - docs/contrib/replyfilter
Compare character with EOF using signed comparison because
[nmh] / docs / contrib / replyfilter
index a080710d53b9fc9a99328a32dc7a223bc30f79f2..7f5b44752660a2bafaae518e38def7f802d57418 100755 (executable)
@@ -68,11 +68,11 @@ $outcharset = 'utf-8';
 $maxcolwidth = 78;
 
 #
-# Out HTML converter program & arguments
+# Out HTML converter program & arguments. charset will be appended
 #
 
 @htmlconv = ('w3m', '-dump', '-cols', $maxcolwidth - 2, '-T', 'text/html',
-            '-O', $outcharset);
+            '-O', $outcharset, '-I');
 
 
 die "Usage: $0 Content-type content-transfer-encoding quote-prefix\n"
@@ -193,7 +193,7 @@ sub process_text (*$$;$)
 
                binmode($input, ':encoding(us-ascii)');
 
-               $decoder = find_decoder($encoding);
+               $decoder = find_decoder(lc($encoding));
                if (! defined $decoder) {
                        return 'EOF';
                }
@@ -321,7 +321,7 @@ sub process_text (*$$;$)
        # Send our input to the filter program
        #
 
-       if (defined %filterreplace) {
+       if (%filterreplace) {
                foreach my $match (keys %filterreplace) {
                         $text =~ s/$match/$filterreplace{$match}/g;
                }
@@ -348,7 +348,7 @@ sub process_html (*$$;$)
        my $filterpid, $prefixpid, $finread, $finwrite;
        my $foutread, $foutwrite, $decoder, $ret;
 
-       if (! defined($decoder = find_decoder($encoding))) {
+       if (! defined($decoder = find_decoder(lc($encoding)))) {
                return 'EOF';
        }
 
@@ -400,7 +400,8 @@ sub process_html (*$$;$)
                # Exec our converter
                #
 
-               exec (@htmlconv) ||
+               my @conv = (@htmlconv, $charset);
+               exec (@conv) ||
                                die "Unable to exec $filterprogram: $!\n";
        } else {
                die "Fork for $htmlconv[0] failed: $!\n";
@@ -535,7 +536,7 @@ sub process_multipart ($$$)
                        $charset = 'us-ascii';
                }
 
-               $encoding = defined $cte ? $cte->param('_') : '7bit';
+               $encoding = defined $cte ? lc($cte->param('_')) : '7bit';
                $name = defined $cdispo ? $cdispo->param('filename') : undef;
 
                 #
@@ -661,15 +662,15 @@ sub null_decoder ($)
 
 sub match_boundary($$)
 {
-       my ($_, $boundary) = @_;
+       my ($line, $boundary) = @_;
 
        return if ! defined $boundary;
 
-       if (substr($_, 0, 2) eq '--') {
-               s/[ \t\r\n]+\Z//;
-               if ($_ eq "--$boundary") {
+       if (substr($line, 0, 2) eq '--') {
+               $line =~ s/[ \t\r\n]+\Z//;
+               if ($line eq "--$boundary") {
                        return 'EOP';
-               } elsif ($_ eq "--$boundary--") {
+               } elsif ($line eq "--$boundary--") {
                        return 'EOM';
                }
        }