X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=docs%2Freplyfilter;h=193dd40b046efc8a14cff09d91e54671c5dce6dd;hb=9e826e368de450dfdaacf38def352d6314c76b62;hp=de81f87c29f26906c0a08c82d950f63b8fab8e75;hpb=523cfc19212197befa73fc59460e93c563b76c9b;p=mmh diff --git a/docs/replyfilter b/docs/replyfilter index de81f87..193dd40 100755 --- a/docs/replyfilter +++ b/docs/replyfilter @@ -68,7 +68,13 @@ die "Usage: $0 Content-type content-transfer-encoding quote-prefix\n" if $#ARGV != 2; if ($ARGV[0] ne "") { - $content_type = Mail::Field->new('Content-Type', $ARGV[0]); + my $ctype = Mail::Field->new('Content-Type', $ARGV[0]); + $content_type = $ctype->type; + $charset = $ctype->charset; + $boundary = $ctype->boundary; +} else { + $content_type = 'text/plain'; + $charset = 'us-ascii'; } $encoding = $ARGV[1] eq "" ? '7bit' : lc($ARGV[1]); @@ -85,8 +91,8 @@ binmode(STDOUT, ":encoding($outcharset)"); # to our format subroutine. # -if ($ARGV[0] eq "" || $content_type->type eq 'text/plain') { - process_text(\*STDIN, $encoding, $content_type->charset); +if ($content_type eq 'text/plain') { + process_text(\*STDIN, $encoding, $charset); exit 0; } @@ -98,7 +104,7 @@ if ($ARGV[0] eq "" || $content_type->type eq 'text/plain') { # Put markers in the output for other content types. # -($type) = (split('/', $content_type->type)); +($type) = (split('/', $content_type)); if ($type eq 'multipart') { @@ -107,9 +113,7 @@ if ($type eq 'multipart') { # Eat the MIME prologue (everything up until the first boundary) # - $boundary = $content_type->boundary; - - if ($boundary eq '') { + if (! defined $boundary || $boundary eq '') { print "No boundary in Content-Type header!\n"; eat_part(\*STDIN); exit 1; @@ -127,12 +131,11 @@ if ($type eq 'multipart') { undef $boundary; } -process_part(\*STDIN, $content_type->type, $encoding, $content_type->charset, - $boundary); +process_part(\*STDIN, $content_type, $encoding, $charset, $boundary); if ($boundary) { # - # Eat the MIME eplilog + # Eat the MIME epilog # eat_part(\*STDIN); } @@ -156,7 +159,7 @@ sub process_text (*$$;$) # quote character # - if ($encoding eq '7bit' || $encoding ne '8bit') { + if ($encoding eq '7bit' || $encoding eq '8bit') { while (<$input>) { $ret = match_boundary($_, $boundary); if (defined $ret) { @@ -215,7 +218,7 @@ sub process_text (*$$;$) pipe($foutread, $foutwrite) || die "pipe() (second) failed: $!\n"; binmode($finread, ":encoding($outcharset)"); - binmode($finread, ":encoding($outcharset)"); + binmode($finwrite, ":encoding($outcharset)"); binmode($foutread, ":encoding($outcharset)"); binmode($foutwrite, ":encoding($outcharset)");