# HG changeset patch # User heiko # Date 1189034145 0 # Node ID 1fccf68e52c6f9b29cba12154927d50bc3921e1b # Parent af315e1a9b1ec48a1bf0664d2b68dfc23ba21c6c - weitere Versuche diff -r af315e1a9b1e -r 1fccf68e52c6 Makefile --- a/Makefile Wed Sep 05 14:52:16 2007 +0000 +++ b/Makefile Wed Sep 05 23:15:45 2007 +0000 @@ -1,4 +1,4 @@ -BIN = mimecut +BIN = mimecut hs12 CLEANFILES = $(BIN) .PHONY: all clean install test @@ -6,7 +6,11 @@ all: $(BIN) test: all - prove --timer t/ + @rm .verbose 2>/dev/null && O=--verbose;\ + prove $$O --timer t/ + +verbose: + @touch .verbose clean: ; -rm -f $(CLEANFILES) diff -r af315e1a9b1e -r 1fccf68e52c6 hs12 --- a/hs12 Wed Sep 05 14:52:16 2007 +0000 +++ b/hs12 Wed Sep 05 23:15:45 2007 +0000 @@ -1,36 +1,40 @@ #! /usr/bin/perl + use strict; use warnings; use Fatal qw(:void select); use File::Temp qw(tempfile); -use Smart::Comments; +use if $ENV{DEBUG} => "Smart::Comments"; sub print_message(*$); sub read_message(); sub pass_mime($); sub forward_to_boundary($*); -sub read_header(*); -sub process(*$); +sub read_header(*$); +sub process(*$$); MAIN: { my $message = read_message(); my $tmpout = tempfile(); - my $stdout = select $tmpout; + my $stdout = select $tmpout; # print ab jetzt ins tmpout seek($message, 0, 0); - process($message, undef); + process($message, undef, undef); # spit out everthing select $stdout; seek($tmpout, 0, 0); - { # the tmpout may contain only parts of the message - # to avoid unnessesary copy actioins + # now output the stuff collected in tmpout + # and the rest of the message + { local $/ = \10240; print while <$tmpout>; print while <$message>; } + + exit 0; } sub print_message(*$) { @@ -46,27 +50,36 @@ } } -sub process(*$) { - my ($m, $boundary) = shift; - my ($header, %header) = read_header($m); - my $mime; +sub process(*$$) { + my ($m, $boundary, $mime_version) = @_; + my ($header, %header) = read_header($m, $boundary); + my $mime_type; - if ( $header{"mime-version"} + $mime_version ||= $header{"mime-version"}; + + ### $header + + if ( $mime_version and $header{"content-type"}) { - ($mime, undef, $boundary) = ( + ($mime_type, undef, $boundary) = ( $header{"content-type"} =~ /^(.*?); # mime type (?:.*(?:boundary=(['"])(.*?)\2))? # eventuell noch mehr /x ); } - if (!$mime or pass_mime($mime)) { + if (not $mime_type or pass_mime($mime_type)) { + warn "passing: " . ($mime_type ? $mime_type : "no mime_type") . "\n"; print $header; print_message($m, $boundary); return; } + else { + warn "not just passing: $mime_type\n"; + } + process($m, $boundary, $mime_version); } @@ -86,19 +99,27 @@ # in: current message file handle # out: ($orignal_header, %parsed_header) -sub read_header(*) { - my $msg = shift; - my ($from, $h); +sub read_header(*$) { + my ($msg, $start) = @_; + my $h = ""; - local $_ = <$msg>; - $from = /^from\s/i ? $_ : ""; + if (defined $start) { + while (<$msg>) { + $h .= $_; + last if /^--$start\s*$/; + } + } - while (<$msg>) { $h .= $_; last if /^\s*$/ } - $_ = $h; + while (<$msg>) { + $h .= $_; + last if /^\s*$/; + } + + $_ = $h; # unmodified header (excl. $from) s/\r?\n\s+(?=\S)/ /gm; # continuation lines s/^(\S+):/\L$1:/gm; # header fields to lower case - return ("$from$h", ":unix_from:" => split(/^(\S+):\s*/m, "$from$_")); + return ($h, ":unix_from:" => split(/^(\S+):\s*/m, $_)); } __END__ diff -r af315e1a9b1e -r 1fccf68e52c6 messages/plain.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messages/plain.out Wed Sep 05 23:15:45 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 diff -r af315e1a9b1e -r 1fccf68e52c6 messages/signed.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/messages/signed.out Wed Sep 05 23:15:45 2007 +0000 @@ -0,0 +1,132 @@ +From bounce-debian-user-german=hs=schlittermann.de@lists.debian.org Mon Sep 03 17:38:53 2007 +Received: from uucp by jumper.schlittermann.de with local-rmail (Exim 4.63) + (envelope-from ) + id 1ISE0r-0004Ok-KE + for heiko@jumper.schlittermann.de; Mon, 03 Sep 2007 17:38:53 +0200 +Received: from cyrus by ssl.schlittermann.de with local (Exim 4.63) + (envelope-from ) + id 1ISDwP-00023b-Io + for heiko@jumper.schlittermann.de; Mon, 03 Sep 2007 17:34:17 +0200 +Received: from ssl.schlittermann.de ([unix socket]) + by pu (Cyrus v2.2.13-Debian-2.2.13-0.4.ius.stable) with LMTPA; + Mon, 03 Sep 2007 17:34:17 +0200 +X-Sieve: CMU Sieve 2.2 +Received: from scanner.schlittermann.de ([212.80.235.140]) + by ssl.schlittermann.de with esmtp (Exim 4.63) + (envelope-from ) + id 1ISDwP-00023T-9h + for hs@schlittermann.de; Mon, 03 Sep 2007 17:34:17 +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 etEIcw56mc1b for ; + Mon, 3 Sep 2007 17:34:16 +0200 (CEST) +Received: from murphy.debian.org ([70.103.162.31]) + by ssl.schlittermann.de with esmtp (Exim 4.63) + (envelope-from ) + id 1ISDwH-000227-6R + for hs@schlittermann.de; Mon, 03 Sep 2007 17:34:13 +0200 +Received: from localhost (localhost [127.0.0.1]) + by murphy.debian.org (Postfix) with QMQP + id 2BA702E7A4; Mon, 3 Sep 2007 15:40:29 +0000 (UTC) +Old-Return-Path: +X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-26) on murphy.debian.org +X-Spam-Status: No, score=-7.3 required=4.0 tests=AWL,BAYES_00,LDOSUBSCRIBER, + SPF_PASS autolearn=ham version=3.1.4 +X-Original-To: debian-user-german@lists.debian.org +Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) + by murphy.debian.org (Postfix) with SMTP id 8AA922E6E9 + for ; Mon, 3 Sep 2007 15:40:21 +0000 (UTC) +Received: (qmail invoked by alias); 03 Sep 2007 15:33:43 -0000 +Received: from pD95D3374.dip0.t-ipconnect.de (EHLO kiste.home.zz) [217.93.51.116] + by mail.gmx.net (mp036) with SMTP; 03 Sep 2007 17:33:43 +0200 +X-Authenticated: #636122 +X-Provags-ID: V01U2FsdGVkX1+EVgAKYkaEHifj89tKEtKSvw8bFiMfD1wz7Sl+VW + Bjno2WJ62Zdjmi +Received: from uk by kiste.home.zz with local (Exim 4.63) + (envelope-from ) + id 1ISDvr-0001tq-BJ + for debian-user-german@lists.debian.org; Mon, 03 Sep 2007 17:33:43 +0200 +Date: Mon, 3 Sep 2007 17:33:43 +0200 +From: Uwe Kerstan +To: debian-user-german@lists.debian.org +Message-ID: <20070903153343.GA5367@kiste.home.zz> +Mail-Followup-To: debian-user-german@lists.debian.org +References: <8Z2Q8-5sF-15@gated-at.bofh.it> <8Z67m-2hf-13@gated-at.bofh.it> <8ZhP5-3BY-15@gated-at.bofh.it> <8ZjHe-6F4-3@gated-at.bofh.it> <0MKxQS-1ISC0q3VR5-000887@mrelayeu.kundenserver.de> +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="Q68bSM7Ycu6FN28Q" +Content-Disposition: inline +In-Reply-To: <0MKxQS-1ISC0q3VR5-000887@mrelayeu.kundenserver.de> +X-Priority: normal +Organization: CoLUG +X-Face: )M4WRmNYmN{3M5vXo_nkM-A3^OAc,/Hr_@z~#Y[$%&ju~oLC)p`Lp5E*~y]D=|BKd_ACwSi + L*"9GpEgRUAPbGg3Sbcy%'4tzZkb[ +Resent-From: debian-user-german@lists.debian.org +X-Mailing-List: archive/latest/215987 +X-Loop: debian-user-german@lists.debian.org +List-Id: +List-Post: +List-Help: +List-Subscribe: +List-Unsubscribe: +Precedence: list +Resent-Sender: debian-user-german-request@lists.debian.org +Resent-Date: Mon, 3 Sep 2007 15:40:29 +0000 (UTC) +X-IUS-Spam-Comment: scanned on ssl.schlittermann.de hash:35FCFDF61F49A167A89EABD0CC15386592069464 +X-IUS-Spam-Score: -2.4 +X-IUS-Spam-Level: -- +X-IUS-Spam-Report: AWL=0.155,BAYES_00=-2.599 +Subject: Re: ZDF Mediathek funktioniert nicht im Firefox u.a. Browsern + +--Q68bSM7Ycu6FN28Q +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +* A.net.te_und_Mi.cha.el_Glo.cken.stein [03-09-2007 15:30]: + +> Da scheint es aber ein Problem mit JavaScript zu sein, ich bekomme +> nur einen grauen Hintergrund, nicht mal eine Auswahl von Optionen +> oder Filmen. Bin lieber mit dem Konqueror unterwegs, schade. + +Der Javascript scheint ein paar Macken zu haben. Bei mir geht es +mit vlc-plugin und mplayer-plugin. vlc-plugin hat leider keine +Steuerelemente, mplayer-plugin hat etwas geruckelt, da kann man +an den Cache-Optionen drehen, dann wird es besser. Wenn man +zu einem anderen Film wechselt, st=FCrzt der Iceweasel manchmal ab. +Alternative Links auf die Videos w=E4ren w=FCnschenswert... + +Gru=DF Uwe + +--Q68bSM7Ycu6FN28Q +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFG3ClXtReBfnaTvyIRAsmZAKCHsUGjg07DYXS8x+HbnVjTlOTrKwCcD1Lx +OFqTZ8TAcGvQfRwLsgTAEF0= +=kwDw +-----END PGP SIGNATURE----- + +--Q68bSM7Ycu6FN28Q-- + + +-- +Haeufig gestellte Fragen und Antworten (FAQ): +http://www.de.debian.org/debian-user-german-FAQ/ + +Zum AUSTRAGEN schicken Sie eine Mail an debian-user-german-REQUEST@lists.debian.org +mit dem Subject "unsubscribe". Probleme? Mail an listmaster@lists.debian.org (engl) + + diff -r af315e1a9b1e -r 1fccf68e52c6 t/00-vip-from.t --- a/t/00-vip-from.t Wed Sep 05 14:52:16 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -use Test::More tests => 2; -use strict; -use warnings; - -my $x = "a"; - -is($x, "a"); -like($x, qr/a/); - - -__END__ -use Fatal qw(:void open close seek); -use FindBin qw($Bin); - -use IO::File; - -my $out = new_tmpfile IO::File; -my $err = new_tmpfile IO::File; - - -my $pid = open(CUTTER, "|-") or do { - open(STDERR, ">&", $err); - open(STDOUT, ">&", $out); - exec "../mimecut"; - die "Can't exec: $!\n"; -}; - -open(X, "$Bin/mail1.eml"); - -print CUTTER ; -close(CUTTER); - -seek($out, 0, 0); -print <$out>; diff -r af315e1a9b1e -r 1fccf68e52c6 t/10-x.t --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/t/10-x.t Wed Sep 05 23:15:45 2007 +0000 @@ -0,0 +1,48 @@ +use Test::More tests => 2; +use strict; +use warnings; +use Fatal qw(:void open seek truncate); +use FindBin qw($Bin); +use File::Temp qw(tempfile);; +use File::Compare; + +my $MIMECUT = "$Bin/../hs12"; + +my $tmpout = tempfile(); +open(my $saveout, ">&STDOUT"); +open(STDOUT, ">&", $tmpout); + +foreach (qw(plain signed)) { + seek($tmpout, 0, 0); + truncate($tmpout, 0); + + system("$MIMECUT <$Bin/../messages/$_.in"); + seek($tmpout, 0, 0); + is(compare($tmpout, "$Bin/../messages/$_.out"), 0, $_); +} + + +__END__ +use Fatal qw(:void open close seek); +use FindBin qw($Bin); + +use IO::File; + +my $out = new_tmpfile IO::File; +my $err = new_tmpfile IO::File; + + +my $pid = open(CUTTER, "|-") or do { + open(STDERR, ">&", $err); + open(STDOUT, ">&", $out); + exec "../mimecut"; + die "Can't exec: $!\n"; +}; + +open(X, "$Bin/mail1.eml"); + +print CUTTER ; +close(CUTTER); + +seek($out, 0, 0); +print <$out>;