--- a/mimecut.pl Fri Sep 07 22:16:36 2007 +0000
+++ b/mimecut.pl Wed Sep 12 14:59:46 2007 +0000
@@ -62,12 +62,31 @@
last if $arg{to} and /^--\Q$arg{to}\E/;
}
}
+my $vips;
sub process(*;@) {
my ($m, %arg) = @_;
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)) {
+ if ($header{$h}) {
+ if ($header{$h} =~ /$vips/) {
+ print $header;
+ local $/ = \10240;
+ print while <$m>;
+ return;
+ }
+ }
+ }
+ }
+
if ($header{"content-type"}) {
($type) = ($header{"content-type"} =~ /^([^;]*)/);
(undef, $boundary)
@@ -76,50 +95,42 @@
### 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);
- }
+ $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;
+ }
- 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;
+ }
+ }
}
{
--- a/vips.conf Fri Sep 07 22:16:36 2007 +0000
+++ b/vips.conf Wed Sep 12 14:59:46 2007 +0000
@@ -2,5 +2,4 @@
#
# insert vip addresses who will receive uncut messages
# one per line
-info@siemens.ch
-pitti@platsch.de
+mailings@gmx.net