From 59f87ac047552c79d2885106c9dde3967563190a Mon Sep 17 00:00:00 2001 From: Gerfried Fuchs Date: Wed, 17 Feb 2010 20:28:55 +0100 Subject: [PATCH] Imported Upstream version 1.99.1+2.0-rc2 --- ChangeLog | 41 +++++++++++++++++++++++++++++++ TODO | 26 ++++++++++---------- contrib/filter_innd.pl | 17 +++++++++---- t-prot | 55 +++++++++++++++++++++++++----------------- t-prot.1 | 21 +++++++++++++--- 5 files changed, 116 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27be480..cd3d928 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,44 @@ +2005-04-25 16:35 Jochen Striepe + + * t-prot: Release as v1.101. + +2005-04-25 15:49 Jochen Striepe + + * t-prot: We must not forget to remove ad and mailing list footers + within the first MIME/Multipart attachment when processing raw + messages (lacking -M). + +2005-04-25 15:29 Jochen Striepe + + * t-prot: Fix a comment. + +2005-04-25 15:28 Jochen Striepe + + * t-prot: Mailing list footers (and probably ad footers) were not + detected when processing raw MIME/Multipart messages: We have to + look at the very end of the message, not only at the end of the + first attachment. Fix this by calling remove_footers() before + dealing with raw multipart attachments. + +2005-04-15 14:08 Jochen Striepe + + * t-prot: Release as v1.100. + +2005-04-15 14:07 Jochen Striepe + + * contrib/filter_innd.pl: We don't submit any headers, so use + --body. Use unlink() instead of system(). Mention the temp file + problem. + +2005-04-15 14:03 Jochen Striepe + + * t-prot, t-prot.1: Add --body to make sure we are not looking for + any headers when there are none in the input. + +2005-04-15 13:42 Jochen Striepe + + * t-prot.1: Add some clarifications and missing details. + 2005-03-31 19:39 Jochen Striepe * contrib/t-prot.sl: Use S-Lang calls popen(), fputs(), and diff --git a/TODO b/TODO index 5e74b10..ccb134e 100644 --- a/TODO +++ b/TODO @@ -10,13 +10,12 @@ email to . Known Bugs (more severe ones come first) -======================================== - +---------------------------------------- (none) Wishlist -======== +-------- * Better heuristics for M$ style TOFU. The actual algorithm still is just too greedy (actually, it simply snips most things down to the signature). User ignorance makes it tricky to detect gold inside the @@ -28,7 +27,7 @@ graph using these both). Rejected issues -=============== +--------------- * If you set mutt's display_filter to "tee foo" when viewing a pgp signed message and attach the resulting file to a pgp signed message, the result is confusion when displaying this new message with t-prot. @@ -39,19 +38,20 @@ that you can turn it off with just one key stroke. It is definitely not t-prot's responsibility to make *everything* look good and readable. -Known Bugs for t-prot.sl (more severe ones come first) -====================================================== - * Mailing list footers seem not always to be snipped correctly -from MIME/multipart messages if called by t-prot.sl. + TODO LIST FOR T-PROT.SL + ======================= -Wishlist for t-prot.sl -====================== +Wishlist +-------- Known problems: * t-prot.sl interacts badly with some other macros using the -read_article_hook. - * ESC-0/ESC-1 as described in t-prot.sl does not take effect on the -article currently displayed (just on those processed later on). +read_article_hook. We should at least document the What and Why. Anyone +with some more S-Lang experience volunteering for this? ;) + * ESC-6/ESC-7 as described in t-prot.sl does not take effect on the +article currently displayed (just on those processed later on). It would +be nice to have an alternative taking effect immediately. + Please remember that t-prot.sl is an *example* script (for you to get an idea on how to integrate t-prot into other software), so these are diff --git a/contrib/filter_innd.pl b/contrib/filter_innd.pl index dd6985a..4df4bb9 100644 --- a/contrib/filter_innd.pl +++ b/contrib/filter_innd.pl @@ -1,5 +1,5 @@ -# $Id: filter_innd.pl,v 1.4 2004/10/10 20:26:24 jochen Exp $ -# Copyright (c) 2004 Jochen Striepe +# $Id: filter_innd.pl,v 1.5 2005/04/15 14:07:11 jochen Exp $ +# Copyright (c) 2004-2005 Jochen Striepe # # This file is provided as an example how t-prot can be used for # Perl filtering with INN2. It is NOT meant for production use. @@ -30,11 +30,18 @@ sub filter_art { my $rval = "" ; # Assume we'll accept. Cannot be `0' +# Here we only filter local.* news groups. Another useful idea is to +# filter just locally submitted articles: +# if (index($hdr{'Path'}, '!')<0) { if ($hdr{'Newsgroups'} =~ /^local\./) { my $foo = $hdr{'__BODY__'}; $foo =~ s/\r\n/\n/gs; - open(TMP, '/usr/bin/mktemp -q /tmp/INN2.tmp.XXXXXX | tr -d \'\n\'|') +# Note that here might be a security problem lurking. The directory +# used for temporary files should not be writable for anyone but the +# user INN runs as. As mentioned above, this example file is NOT +# meant for production use. + open(TMP, '/usr/bin/mktemp -q /tmp/INN2/tmp.XXXXXX | tr -d \'\n\'|') || return ''; my $f = ; close TMP; @@ -44,12 +51,12 @@ sub filter_art { print OUT $foo; close OUT; - open(IN, "/usr/bin/t-prot -m -t -p --check -i $f|") + open(IN, "/usr/bin/t-prot -m -t -p --body --check -i $f|") || goto FINISH; $rval = ; close IN; - FINISH: system('/bin/rm', $f); + FINISH: unlink($f); } $rval ; diff --git a/t-prot b/t-prot index 936928c..ee84667 100755 --- a/t-prot +++ b/t-prot @@ -1,13 +1,13 @@ #!/usr/bin/perl -w -# $Id: t-prot,v 1.230 2005/03/24 22:24:29 jochen Exp $ +# $Id: t-prot,v 1.236 2005/04/25 16:35:56 jochen Exp $ require 5.006; use strict; use Fcntl qw(O_EXCL O_WRONLY O_CREAT); use Getopt::Mixed qw(nextOption); -use constant VER => '1.99'; +use constant VER => '1.101'; use constant REV => ''; -use constant REL => q$Revision: 1.230 $=~m/(\d+(?:\.\d+)+)/; +use constant REL => q$Revision: 1.236 $=~m/(\d+(?:\.\d+)+)/; # MTA expecting mail on STDIN # (you might have to adjust this if using a different MTA) use constant SENDMAIL => '/usr/sbin/sendmail -oi'; @@ -24,8 +24,8 @@ use vars qw( $ad $ads $bigqn $bigqx $boun $check $check_ratio $cr $diff $elli $footers $ftr_ad $ftr_ml $hdrs $indent $kamm $kdiff $kminl $kmaxl $lax $lsig $maxsig $mda $ml $ms $ms_smart $msg_quote $msg_ratio - $mua $ofile $pgpshort $pgpmove $pgpmovevrf $sig $sigint $sign - $spass $spass_prefix $sysl $trad $trsp + $mua $nohdr $ofile $pgpshort $pgpmove $pgpmovevrf $sig $sigint + $sign $spass $spass_prefix $sysl $trad $trsp $gpg_WARNING $gpg_Warning $gpg_Cantcheck $gpg_aka $gpg_bad $gpg_expired $gpg_good $gpg_bug @@ -90,6 +90,8 @@ sub help { -A=DIRECTORY ad footer directory, treat ad footers as signature --bigq[=n[,x]] remove all but x lines of quotes with more than n lines; default is n=30 and x=10 + --body input has no headers; does not work with --pgp-short; + multipart messages will not be detected -c merge multiple blank lines --check[=FLAGS] check various criteria, print error message and quit; see man page for details @@ -425,17 +427,24 @@ sub process_msg { # First, remove and store lines we might need later... # Remove headers: - for ($x=0; $x<$#$lines; $x++) { if (@$lines[$x] =~ /^$/) { last; }; } - @hdr = @$lines[0..$x]; - splice(@$lines, 0, $x+1); + if (!$nohdr) { + for ($x=0; $x<$#$lines; $x++) { if (@$lines[$x] =~ /^$/) { last; }; } + @hdr = @$lines[0..$x]; + splice(@$lines, 0, $x+1); + } # remember the original body lines count my $linecount = scalar(@$lines); + # Remove ML footers: + remove_footers($lines, \@ftr, $footers, undef, $ftr_ml); + + # Remove ad footers: + remove_footers($lines, \@ads, $ads, undef, $ftr_ad); # See if we have a multipart content type. If yes, see if it is already - # ripped (e.g. by mutt(1)), otherwise only leave the first part if it - # is plain text (if not, we are done - non-text messages are not our - # business). + # ripped (e.g. by you MUA, assuming it does not get special treatment with + # --mua=foo), otherwise only leave the first part if it is plain text (if + # not, we are done - non-text messages are not our business). if ($mua ne 'mutt') { for ($x=0; $xd diff ftr-ad ftr-ml help>h kminl=i'. - ' kmaxl=i kdiff=i lax-security locale=s ms-smart mua>M pgp-short'. - ' pgp-move pgp-move-vrf sigsmax:i spass version>v'); + ' s t v w bigq:s body check:s debug>d diff ftr-ad ftr-ml help>h'. + ' kminl=i kmaxl=i kdiff=i lax-security locale=s ms-smart mua>M'. + ' pgp-short pgp-move pgp-move-vrf sigsmax:i spass version>v'); while (my ($opt, $val, $pretty) = nextOption()) { if ($opt eq 'a') { $ad = 1; } elsif ($opt eq 'A') { $ads = $val; } @@ -867,6 +876,7 @@ while (my ($opt, $val, $pretty) = nextOption()) { $bigqx = $2?$2:10; if ($bigqn<=0 || $bigqx<=0 || $bigqn<=$bigqx) { help(); } } + elsif ($opt eq 'body') { $nohdr = 1; $hdrs = 1; } elsif ($opt eq 'c') { $cr = 1; } elsif ($opt eq 'check') { $check = 1; @@ -921,6 +931,7 @@ while (my ($opt, $val, $pretty) = nextOption()) { Getopt::Mixed::cleanup(); if (($ml && $footers eq '')|| # no -l without -L ($ad && $ads eq '')|| # no -a without -A + ($nohdr && $pgpshort)|| # --body and --pgp-short are like oil and water ($ifile eq '')|| # no empty -i ($ofile eq '')) # no empty -o { help(); } diff --git a/t-prot.1 b/t-prot.1 index af5ec53..223463b 100644 --- a/t-prot.1 +++ b/t-prot.1 @@ -1,6 +1,6 @@ -.\" $Id: t-prot.1,v 1.97 2005/02/24 23:34:29 jochen Exp $ +.\" $Id: t-prot.1,v 1.99 2005/04/15 14:03:39 jochen Exp $ .\" -.TH T-PROT "1" "Feb 2005" "T-PROT" +.TH T-PROT "1" "Apr 2005" "T-PROT" .SH NAME t-prot \- TOFU Protection - Display Filter for RFC 822 messages .SH SYNOPSIS @@ -17,6 +17,11 @@ message conforming to RFC 822 or it's successor, RFC 2822. Messages conforming to RFCs 2045, 2046 and 2049 should be treated reasonably correct. .PP +Already reformatted messages are handled well: the script was +initially designed to cope with the output of the MUA mutt (which +is the reason for not using standard CPAN modules for handling +messages). +.PP For easy usage, you can download a file to be included in your ~/.muttrc: .I http://www.escape.de/users/tolot/mutt/t-prot/muttrc.t-prot .br @@ -62,6 +67,14 @@ is specified. Blocks of quotes with more than n lines will be shrinked to x lines. Defaults are 30 for n and 10 for x. .TP +.B "\-\-body" +Input consists just of the message's body. There are no RFC 822 header +lines. +.br +.IR NOTE : +This does not work with --pgp-short, and multipart messages will not +be detected due to missing headers. +.TP .B "\-c" "compress": Squeezes a sequence of blank lines to two blank lines at maximum. @@ -298,8 +311,8 @@ If we really find some TOFU, abort with exit code Otherwise redirect the message to ADDRESS if given. .sp Intended for use from within mail delivery agents (MDAs) or mail transport -agents (MTAs), so the message bounces if TOFU is detected, and does not get -on *your* nerves. :) +agents (MTAs), or even from with INN, so the message bounces if TOFU is +detected, and does not get on *your* nerves. :) .sp As an example for usage with .BR sendmail , -- 2.39.2