--- a/mimecut.pl Thu Nov 01 21:42:39 2007 +0000
+++ b/mimecut.pl Thu Nov 01 21:51:49 2007 +0000
@@ -69,23 +69,24 @@
my ($header, %header) = read_header($m);
my ($type, $boundary);
- if (!$vips) {
-
- open(my $fh, "<$CONFDIR/vips.conf")
- or die "can't read $CONFDIR/vips.conf!\n";
- $vips = qr{@{[join "|", map { chomp; "(?:".quotemeta($_).")" } grep !/(?:^\s*#|^\s*$)/, <$fh>]}};
-
- foreach my $h (qw(from to cc bcc return-path envelope-to)) {
- if ($header{$h}) {
- if ($header{$h} =~ /$vips/i) {
- print $header;
- local $/ = \10240;
- print while <$m>;
- return;
- }
- }
- }
- }
+ if (!$vips) {
+
+ open(my $fh, "<$CONFDIR/vips.conf")
+ or die "can't read $CONFDIR/vips.conf!\n";
+ $vips
+ = qr{@{[join "|", map { chomp; "(?:".quotemeta($_).")" } grep !/(?:^\s*#|^\s*$)/, <$fh>]}};
+
+ foreach my $h (qw(from to cc bcc return-path envelope-to)) {
+ if ($header{$h}) {
+ if ($header{$h} =~ /$vips/i) {
+ print $header;
+ local $/ = \10240;
+ print while <$m>;
+ return;
+ }
+ }
+ }
+ }
if ($header{"content-type"}) {
($type) = ($header{"content-type"} =~ /^([^;]*)/);
@@ -95,42 +96,44 @@
### type: $type
### bound: $boundary
}
- $boundary ||= $arg{boundary};
- if (not $type or pass_mime($type)) {
- #warn "passing: " . ($type ? $type : "no mime type") . "\n";
- print $header;
- print_message($m, to => $boundary);
- return;
- }
- if ($type =~ m{^multipart/}) {
- #warn "forward to next multipart boundary: $boundary\n";
- print $header;
- print_message($m, to => $boundary);
- while (not eof($m)) {
- process($m, boundary => $boundary);
- }
- return;
- }
+ $boundary ||= $arg{boundary};
+ if (not $type or pass_mime($type)) {
+
+ #warn "passing: " . ($type ? $type : "no mime type") . "\n";
+ print $header;
+ print_message($m, to => $boundary);
+ return;
+ }
+ if ($type =~ m{^multipart/}) {
+
+ #warn "forward to next multipart boundary: $boundary\n";
+ print $header;
+ print_message($m, to => $boundary);
+ while (not eof($m)) {
+ process($m, boundary => $boundary);
+ }
+ return;
+ }
- #warn "removed: $type\n";
+ #warn "removed: $type\n";
- my ($eol) = ($header =~ /(\s*)$/);
- $header =~ s/\s*$//;
- $header =~ s/^/-- /gm;
+ my ($eol) = ($header =~ /(\s*)$/);
+ $header =~ s/\s*$//;
+ $header =~ s/^/-- /gm;
- print "Content-Type: text/plain"
- . $eol x 2
- . "Content removed ("
- . localtime() . ")$eol"
- . $header
- . $eol;
+ print "Content-Type: text/plain"
+ . $eol x 2
+ . "Content removed ("
+ . localtime() . ")$eol"
+ . $header
+ . $eol;
- while (<$m>) {
- if (/^--\Q$boundary\E/) {
- print;
- last;
- }
- }
+ while (<$m>) {
+ if (/^--\Q$boundary\E/) {
+ print;
+ last;
+ }
+ }
}
{
@@ -142,7 +145,8 @@
if (!$re) {
open(my $fh, "<$CONFDIR/mimes.conf")
or die "can't read $CONFDIR/mimes.conf!\n";
- $re = qr{@{[join "|", map { chomp; "(?:".quotemeta($_).")" } grep !/(?:^\s*#|^\s*$)/, <$fh>]}};
+ $re
+ = qr{@{[join "|", map { chomp; "(?:".quotemeta($_).")" } grep !/(?:^\s*#|^\s*$)/, <$fh>]}};
}
return $type =~ /$re/i;
}