# HG changeset patch # User heiko # Date 1189003936 0 # Node ID af315e1a9b1ec48a1bf0664d2b68dfc23ba21c6c # Parent 26659f592363363f3c79df4434a0b7d324b4c50c - na ja, noch wirklich ist das nicht die Lösung diff -r 26659f592363 -r af315e1a9b1e hs12 --- a/hs12 Wed Sep 05 08:53:01 2007 +0000 +++ b/hs12 Wed Sep 05 14:52:16 2007 +0000 @@ -6,12 +6,12 @@ use File::Temp qw(tempfile); use Smart::Comments; +sub print_message(*$); sub read_message(); -sub parse(*); sub pass_mime($); sub forward_to_boundary($*); sub read_header(*); -sub process(*); +sub process(*$); MAIN: { my $message = read_message(); @@ -19,7 +19,7 @@ my $stdout = select $tmpout; seek($message, 0, 0); - process($message); + process($message, undef); # spit out everthing select $stdout; @@ -33,36 +33,41 @@ } } -sub process(*) { - my $m = shift; - my ($header, %header) = read_header($m); +sub print_message(*$) { + my ($m, $b) = @_; + + if (not defined $b) { + return print while <$m>; + } + + while (<$m>) { + print; + last if /^--$b--\s*/; + } +} - if ( !$header{"mime-version"} - or !$header{"content-type"}) +sub process(*$) { + my ($m, $boundary) = shift; + my ($header, %header) = read_header($m); + my $mime; + + if ( $header{"mime-version"} + and $header{"content-type"}) { + ($mime, undef, $boundary) = ( + $header{"content-type"} =~ /^(.*?); # mime type + (?:.*(?:boundary=(['"])(.*?)\2))? # eventuell noch mehr + /x + ); + } + + if (!$mime or pass_mime($mime)) { print $header; + print_message($m, $boundary); return; } - if (my $boundary = pass_mime($header{"content-type"})) { - warn "passing ", ($header{"content-type"} =~ /^(.*?);/)[0], "\n"; - print $header; - while (<$m>) { print; last if /^--\Q$boundary\E--\s*/ } - } - - #my $boundary; - #$boundary = $2 - # if ($header{"content-type"} =~ m{boundary=(['"])(.*?)\1}); - -} - -sub forward_to_boundary($*) { - my ($b, $fh) = @_; - while (<$fh>) { - print; - return if /^--$b/; - } } sub pass_mime($) { @@ -97,8 +102,3 @@ return ("$from$h", ":unix_from:" => split(/^(\S+):\s*/m, "$from$_")); } __END__ - -my $parser = new MIME::Parser; - -# read the complete mail -my $entity = $parser->parse(\*STDIN); diff -r 26659f592363 -r af315e1a9b1e messages/plain.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messages/plain.in Wed Sep 05 14:52:16 2007 +0000 @@ -0,0 +1,52 @@ +From lug-dd-bounces@mailman.schlittermann.de Wed Sep 05 15:54:11 2007 +Received: from uucp by jumper.schlittermann.de with local-rmail (Exim 4.63) + (envelope-from ) + id 1ISvKd-0005xY-TH + for heiko@jumper.schlittermann.de; Wed, 05 Sep 2007 15:54:11 +0200 +Received: from cyrus by ssl.schlittermann.de with local (Exim 4.63) + (envelope-from ) + id 1ISvJ7-0000I4-Ez + for heiko@jumper.schlittermann.de; Wed, 05 Sep 2007 15:52:37 +0200 +Received: from ssl.schlittermann.de ([unix socket]) + by pu (Cyrus v2.2.13-Debian-2.2.13-0.4.ius.stable) with LMTPA; + Wed, 05 Sep 2007 15:52:37 +0200 +X-Sieve: CMU Sieve 2.2 +Received: from localhost ([127.0.0.1] helo=pu.schlittermann.de) + by ssl.schlittermann.de with esmtp (Exim 4.63) + (envelope-from ) + id 1ISvJ6-0000EV-MT; Wed, 05 Sep 2007 15:52:36 +0200 +Received: from scanner.schlittermann.de ([212.80.235.140]) + by ssl.schlittermann.de with esmtp (Exim 4.63) + (envelope-from ) id 1ISvIR-0000E5-4j + for lug-dd@mailman.schlittermann.de; Wed, 05 Sep 2007 15:51:55 +0200 +X-Virus-Scanned: Debian amavisd-new at scanner.schlittermann.de +Received: from ssl.schlittermann.de ([212.80.235.130]) + by scanner.schlittermann.de (scanner.schlittermann.de [212.80.235.140]) + (amavisd-new, port 10024) + with ESMTP id G6ViDk9SYaNn for ; + Wed, 5 Sep 2007 15:51:52 +0200 (CEST) +Received: from silmor.de ([217.160.219.75] helo=p15139323.pureserver.info) + by ssl.schlittermann.de with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) + (Exim 4.63) (envelope-from ) id 1ISvI7-0000Au-Jf + for lug-dd@mailman.schlittermann.de; Wed, 05 Sep 2007 15:51:39 +0200 +Received: from pd9eb52c2.dip.t-dialin.net ([217.235.82.194] helo=zaphod.local) + by p15139323.pureserver.info with esmtpsa + (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) + (envelope-from ) id 1ISvHx-0005BE-QG + for lug-dd@mailman.schlittermann.de; Wed, 05 Sep 2007 15:51:25 +0200 +From: Konrad Rosenbaum +To: Linux-User-Group Dresden +Date: Wed, 5 Sep 2007 15:51:25 +0200 +User-Agent: KMail/1.9.6 +References: <200709041804.48445.2005@kuarepoti-dju.net> + <200709050938.25537@zaphod.konrad.silmor.de> + <46DE9079.2040409@gmx.de> +In-Reply-To: <46DE9079.2040409@gmx.de> +MIME-Version: 1.0 +Message-Id: <200709051551.26621@zaphod.konrad.silmor.de> + +Hallo, +das ist nur ein Test, +sonst nichts. +-- +HS