+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
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
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.
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
-# $Id: filter_innd.pl,v 1.4 2004/10/10 20:26:24 jochen Exp $
-# Copyright (c) 2004 Jochen Striepe <t-prot@tolot.escape.de>
+# $Id: filter_innd.pl,v 1.5 2005/04/15 14:07:11 jochen Exp $
+# Copyright (c) 2004-2005 Jochen Striepe <t-prot@tolot.escape.de>
#
# 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.
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 = <TMP>;
close TMP;
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 = <IN>;
close IN;
- FINISH: system('/bin/rm', $f);
+ FINISH: unlink($f);
}
$rval ;
#!/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';
$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
-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
# 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; $x<scalar(@hdr); $x++) {
if ($hdr[$x] =~ /^Content-Type:\s+(.*)$/i) {
}
@bo1 = @$lines[0..$x];
splice(@$lines, 0, $x+1);
+
+ # remove mailing list and ad footers within this
+ # attachment:
+ remove_footers($lines, \@ftr, $footers, undef, $ftr_ml);
+ remove_footers($lines, \@ads, $ads, undef, $ftr_ad);
+
last;
}
else {
}
}
- # Remove ML footers:
- remove_footers($lines, \@ftr, $footers, undef, $ftr_ml);
-
- # Remove ad footers:
- remove_footers($lines, \@ads, $ads, undef, $ftr_ad);
-
if ($mua eq 'mutt') {
# See if we find pgp output generated by mutt before we scramble
# the thing. If yes, see if we can beautify it.
# command line switches
($ad, $ads, $bigqn, $bigqx, $check, $cr, $sysl, $diff, $elli, $footers, $lax,
- $ml, $ms, $ms_smart, $mda, $mua, $hdrs, $kamm, $lsig, $sig, $sigint,
+ $ml, $ms, $ms_smart, $mda, $mua, $hdrs, $kamm, $lsig, $nohdr, $sig, $sigint,
$spass, $trad, $trsp) =
- (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+ (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
my $ifile = '-'; # use STDIN if nothing specified
# get command line params:
Getopt::Mixed::init('a A=s c d e h i=s k L=s l m M=s o=s P=s p:s r S:i'.
- ' s t v w bigq:s 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');
+ ' 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; }
$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;
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(); }
-.\" $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
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
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.
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 ,