]> git.deb.at Git - pkg/t-prot.git/commitdiff
Imported Upstream version 1.99.1+2.0-rc2 upstream/1.99.1+2.0-rc2
authorGerfried Fuchs <rhonda@debian.at>
Wed, 17 Feb 2010 19:28:55 +0000 (20:28 +0100)
committerGerfried Fuchs <rhonda@debian.at>
Wed, 17 Feb 2010 19:28:55 +0000 (20:28 +0100)
ChangeLog
TODO
contrib/filter_innd.pl
t-prot
t-prot.1

index 27be480e53354cf812d1d1b77d8b42003b2c7827..cd3d928ad09f01eba61770ab14219a2b3d07afb9 100644 (file)
--- 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
 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 5e74b10d46a51a64668de1d15e195ae096ab6e25..ccb134e4175b89c8c86e93b015c0f4f6414a9902 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,13 +10,12 @@ email to <t-prot@tolot.escape.de>.
 
 
 Known Bugs (more severe ones come first)
 
 
 Known Bugs (more severe ones come first)
-========================================
-
+----------------------------------------
 (none)
 
 
 Wishlist
 (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
     * 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
 
 
 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.
     * 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.
 
 
 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
 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
 
 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
index dd6985a6d541a9fd33938e5727bf25c429b0f74a..4df4bb9130b8a0ca7b5b3b6a9db24fb1e478808a 100644 (file)
@@ -1,5 +1,5 @@
-# $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.
 #
 # 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'
 
 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;
 
        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;
                        || return '';
                my $f = <TMP>;
                close TMP;
@@ -44,12 +51,12 @@ sub filter_art {
                print OUT $foo;
                close OUT;
 
                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;
 
                        || goto FINISH;
                $rval = <IN>;
                close IN;
 
-               FINISH: system('/bin/rm', $f);
+               FINISH: unlink($f);
        }
 
        $rval ;
        }
 
        $rval ;
diff --git a/t-prot b/t-prot
index 936928c9a38720acaada34f0db0069d8317bc933..ee846679214fb2c073f421d2579e3e529888f584 100755 (executable)
--- a/t-prot
+++ b/t-prot
@@ -1,13 +1,13 @@
 #!/usr/bin/perl -w
 #!/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);
 
 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 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';
 # 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
     $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
 
     $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
   -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
   -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:
 
     # 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);
 
     # 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
 
     # 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) {
     if ($mua ne 'mutt') { 
         for ($x=0; $x<scalar(@hdr); $x++) {
             if ($hdr[$x] =~ /^Content-Type:\s+(.*)$/i) {
@@ -483,6 +492,12 @@ sub process_msg {
                                 }
                                 @bo1 = @$lines[0..$x];
                                 splice(@$lines, 0, $x+1);
                                 }
                                 @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 { 
                                 last;
                             }
                             else { 
@@ -525,12 +540,6 @@ sub process_msg {
         }
     }
 
         }
     }
 
-    # 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.
     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.
@@ -848,16 +857,16 @@ my $locale = $ENV{'LC_ALL'}?$ENV{'LC_ALL'}:($ENV{'LC_MESSAGES'}?$ENV{'LC_MESSAGE
 
 # command line switches
 ($ad, $ads, $bigqn, $bigqx, $check, $cr, $sysl, $diff, $elli, $footers, $lax,
 
 # 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) =
     $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'.
 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; }
 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(); }
     }
         $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;
     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
 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(); }
     ($ifile eq '')||             # no empty -i
     ($ofile eq ''))              # no empty -o
 { help(); }
index af5ec539217ac862c7f9149cd76ff139e9dae30c..223463b755844eb40c3fe1d3c5d1f5048fcb8c17 100644 (file)
--- 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
 .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
 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
 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
 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.
 .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 
 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 ,
 .sp
 As an example for usage with
 .BR sendmail ,