+2010-02-11 11:10 Jochen Striepe
+
+ * t-prot: Release as v2.14.
+
+2010-02-11 11:09 Jochen Striepe
+
+ * t-prot: Code cleanup for --pgp-short. Should get better
+ performance now.
+
+2010-02-07 22:41 Jochen Striepe
+
+ * t-prot: Tighten --help output.
+
+2010-02-07 22:10 Jochen Striepe
+
+ * t-prot.1: Add fields of usage and mention the INN2 filter file.
+
+2010-02-07 21:56 Jochen Striepe
+
+ * t-prot.1: Improve word flow.
+
+2010-02-07 16:16 Jochen Striepe
+
+ * t-prot.1: Another occurence of RFC 2822, update to RFC 5322.
+
2010-02-07 14:31 Jochen Striepe
* t-prot.1: RFC 5322 is offficial standard for the Internet Message
+++ /dev/null
-T-PROT AND SUPPORT FOR GETOPT::LONG
-===================================
-
-Most distributions (it seems to me) are quite eager to abandon Getopt::Mixed,
-having Getopt::Long in the official Perl package, which does everything the
-former module did. Getopt::Mixed is unmaintained and marked deprecated by
-its author, so why keep it?
-
-The answer is simple: because it's much faster (GNU time(1) tells me 28%
-faster for running my complete t-prot release test suite consisting of
-real-life emails) than anything I could get out of Getopt::Long. Plus,
-from my point of view, there are no problems having a package installed
-that is well-tested and just works fine (you don't need updates and more
-new shiny features if the software just does what you want it to do).
-
-So we have the choice between easy maintainance and better performance.
-
-
-For the time being, I made my choice and keep sticking to Getopt::Mixed as
-long as it works as-is with current stable perl versions. That does not mean
-I don't see the merits of a well-maintained standard module, which is already
-available on any perl system out there. Thus, a patch is provided to allow
-easy migration to Getopt::Long for anyone who likes this better. I hope
-this solution is fine for everyone.
-
- t-prot -- TOFU protection
- =========================
+T-PROT -- TOFU protection
+=========================
1. What the hell is TOFU?
As the man page says:
Thank you!
2. What does the script do?
- It detects, and when demanded hides annoying parts in rfc2822 messages:
+ It detects, and when demanded hides annoying parts in rfc5322 messages:
TOFU, huge quoted blocks, signatures (especially when they are too long),
excessive punktuation, blocks of empty lines, trailing spaces and tabs.
For use inside of MTAs or MDAs it exits with appropriate libc exit codes,
entire inspiration for this hack came from the "TOFU protection" line of
his script on many usenet postings.
+
+T-PROT AND SUPPORT FOR GETOPT::LONG
+===================================
+
+Most distributions (it seems to me) are quite eager to abandon Getopt::Mixed,
+having Getopt::Long in the official Perl package, which does everything the
+former module did. Getopt::Mixed is unmaintained and marked deprecated by
+its author, so why keep it?
+
+The answer is simple: because it's much faster (GNU time(1) tells me 28%
+faster for running my complete t-prot release test suite consisting of
+real-life emails) than anything I could get out of Getopt::Long. Plus,
+from my point of view, there are no problems having a package installed
+that is well-tested and just works fine (you don't need updates and more
+new shiny features if the software just does what you want it to do).
+
+So we have the choice between easy maintainance and better performance.
+
+For the time being, I made my choice and keep sticking to Getopt::Mixed as
+long as it works as-is with current stable perl versions. That does not mean
+I don't see the merits of a well-maintained standard module, which is already
+available on any perl system out there. Thus, a patch is provided to allow
+easy migration to Getopt::Long for anyone who likes this better. I hope
+this solution is fine for everyone.
+
+++ /dev/null
---- t-prot 2006-06-18 00:45:55.000000000 +0200
-+++ t-prot-M1511 2006-07-11 14:22:56.000000000 +0200
-@@ -32,7 +32,7 @@
-
- $mutt_attachment $mutt_contenttype $mutt_pgpsigned $mutt_beginsigned
- $mutt_pgpclearsigned $mutt_pgpclearsigstart $mutt_pgpencrypted
-- $mutt_pgpoutstart $mutt_pgpoutend
-+ $mutt_pgpoutstart $mutt_pgpoutend $mutt_ssloutstart $mutt_ssloutend
- );
-
-
-@@ -69,6 +69,8 @@
- $mutt_pgpencrypted = '[-- End of PGP/MIME encrypted data --]';
- $mutt_pgpoutstart = '[-- PGP output follows (current time:';
- $mutt_pgpoutend = '[-- End of PGP output --]';
-+$mutt_ssloutstart = '[-- OpenSSL output follows';
-+$mutt_ssloutend = '[-- End of OpenSSL output --]';
-
- # set the defaults to the C locale
- $gpg_WARNING = 'WARNING: ';
-@@ -336,7 +338,7 @@
- for (my $x=0; $x<scalar(@$L); $x++) {
- if ($$V[$x]) { next; }
-
-- if ($$L[$x]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E)/o)
-+ if ($$L[$x]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E|\Q$mutt_ssloutstart\E)/o)
- {
- my $from;
- for (my $m=0; $m<scalar(@$H); $m++) {
-@@ -363,7 +365,7 @@
- splice(@$V, $i, 1);
- $i--;
- }
-- elsif ($$L[$i]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutend\E)/o)
-+ elsif ($$L[$i]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutend\E|\Q$mutt_ssloutend\E)/o)
- {
- if ($pgpmove ||
- ($pgpmovevrf && (!$sigint) && verified($L, $x+1, $i)))
-@@ -693,7 +695,7 @@
- 'Forwarded message',
- 'Weitergeleitete Nachricht / Forwarded Message');
- my $k = 0; # any text above?
-- my $tmp = 0; # flagged if inside PGP output
-+ my $tmp = 0; # flagged if inside PGP or SSL output
-
- DONE: for ($x=0; $x<scalar(@$lines); $x++) {
- if (!$vrb[$x]) {
-@@ -716,9 +718,11 @@
- ((!$spass) || index($$lines[$x], $spass_prefix)!=0))
- {
- if ($mua eq 'mutt' && (!$tmp) &&
-- $$lines[$x] =~
-- /^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E)/o) {
-- $tmp = 1;
-+ ($$lines[$x] =~
-+ /^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E)/o ||
-+ $$lines[$x] =~
-+ /^(?:\e[^\a]+\a)?(?:\Q$mutt_ssloutstart\E)/o)) {
-+ $tmp = 1;
- } elsif ($mua eq 'mutt' && $tmp &&
- ($$lines[$x] =~
- /^(?:\e[^\a]+\a)?(?:\Q$mutt_beginsigned\E)/o ||
-@@ -989,8 +993,8 @@
- Locale::gettext::gettext("[-- Type: %s/%s, Encoding: %s, Size: %s --]\n") =~
- m/^([^%]*)/;
- ($mutt_pgpsigned) =
-- Locale::gettext::gettext("[-- End of signed data --]\n") =~
-- m/^(.*)\n/m;
-+ Locale::gettext::gettext("\n[-- End of signed data --]\n") =~
-+ m/^\n*(.*)\n/m;
- ($mutt_beginsigned) =
- Locale::gettext::gettext("[-- The following data is signed --]\n\n") =~
- m/^(.*)\n/m;
-@@ -998,16 +1002,24 @@
- Locale::gettext::gettext("[-- END PGP SIGNED MESSAGE --]\n") =~
- m/^(.*)\n/m;
- ($mutt_pgpclearsigstart) =
-- Locale::gettext::gettext("[-- BEGIN PGP SIGNED MESSAGE --]\n") =~
-+ Locale::gettext::gettext("[-- BEGIN PGP SIGNED MESSAGE --]\n\n") =~
- m/^(.*)\n/m;
- ($mutt_pgpencrypted) =
- Locale::gettext::gettext("[-- End of PGP/MIME encrypted data --]\n") =~
- m/^(.*)\n/m;
- ($mutt_pgpoutstart) =
-- Locale::gettext::gettext("[-- PGP output follows (current time: %c) --]\n") =~
-- m/^([^%]*)/;
-+ Locale::gettext::gettext("[-- %s output follows%s --]\n") =~
-+ m/^(.*)%s/;
-+ $mutt_pgpoutstart =~ s/%s/PGP/;
- ($mutt_pgpoutend) =
-- Locale::gettext::gettext("[-- End of PGP output --]\n") =~
-+ Locale::gettext::gettext("[-- End of PGP output --]\n\n") =~
-+ m/^(.*)\n/m;
-+ ($mutt_ssloutstart) =
-+ Locale::gettext::gettext("[-- %s output follows%s --]\n") =~
-+ m/^(.*)%s/;
-+ $mutt_ssloutstart =~ s/%s/OpenSSL/;
-+ ($mutt_ssloutend) =
-+ Locale::gettext::gettext("[-- End of OpenSSL output --]\n\n") =~
- m/^(.*)\n/m;
-
- Locale::gettext::textdomain('gnupg');
+++ /dev/null
---- t-prot 2010-02-01 23:34:42.000000000 +0100
-+++ t-prot-gol 2010-02-01 23:35:27.000000000 +0100
-@@ -4,7 +4,7 @@
- require 5.006;
- use strict;
- use Fcntl qw(O_EXCL O_WRONLY O_CREAT);
--use Getopt::Mixed qw(nextOption);
-+use Getopt::Long qw(:config gnu_getopt no_ignore_case);
- use constant VER => '2.13';
- use constant REV => '';
- use constant REL => q$Revision: 1.276 $=~m/(\d+(?:\.\d+)+)/;
-@@ -916,84 +916,83 @@
- (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
-
-+# temp vals:
-+my ($_t1, $_t2, $_t3, $_t4, $_t5, $_t6, $_t7, $_t8, $_t9, $_ta, $_tb) = undef;
-+
- # 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 body check:s debug>d diff ftr-ad ftr-ml groupwise'.
-- ' help>h kminl=i kmaxl=i kdiff=i lax-security locale=s max-lines=i'.
-- ' 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; }
-- elsif ($opt eq 'bigq') {
-- if ($val !~ /^(?:(\d+)(?:,(\d+))?)?$/) { help(); }
-- $bigqn = $1?$1:30;
-- $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;
-- while ($val && $val =~ /^([^,\s]+)(?:,(\S+))?$/) {
-- my $foo = $1;
-- $val = $2;
--
-- if ($foo =~ /^ratio(?:=(0?\.\d+))?$/) {
-- $check_ratio = $1?$1:0.75;
-- }
-- }
-- }
-- elsif ($opt eq 'd') { $sysl = 1; }
-- elsif ($opt eq 'diff') { $diff = 1; }
-- elsif ($opt eq 'e') { $elli = 1; }
-- elsif ($opt eq 'ftr-ad') { $ftr_ad = 1; $ad = 1; }
-- elsif ($opt eq 'ftr-ml') { $ftr_ml = 1; $ml = 1; }
-- elsif ($opt eq 'groupwise') { $gw = 1; }
-- elsif ($opt eq 'i') { $ifile = $val; }
-- elsif ($opt eq 'k') { $kamm = 1; }
-- elsif ($opt eq 'kminl') { $kminl = $val; $kamm = 1; }
-- elsif ($opt eq 'kmaxl') { $kmaxl = $val; $kamm = 1; }
-- elsif ($opt eq 'kdiff') { $kdiff = $val; $kamm = 1; }
-- elsif ($opt eq 'L') { $footers = $val; }
-- elsif ($opt eq 'l') { $ml = 1; }
-- elsif ($opt eq 'lax-security') { $lax = 1; }
-- elsif ($opt eq 'locale') { $locale = $val; }
-- elsif ($opt eq 'm') { $ms = 1; }
-- elsif ($opt eq 'max-lines') { $maxlines = $val; }
-- elsif ($opt eq 'ms-smart') { $ms_smart = 1; $ms = 1; }
-- elsif ($opt eq 'M') {
-- $mua = lc($val);
-+if (!Getopt::Long::GetOptions(
-+ 'a' => \$ad,
-+ 'A=s' => \$ads,
-+ 'bigq:s' => \$_t1,
-+ 'c' => \$cr,
-+ 'check:s' => \$_t9,
-+ 'debug|d' => \$sysl,
-+ 'diff' => \$diff,
-+ 'e' => \$elli,
-+ 'ftr-ad' => \$ftr_ad,
-+ 'ftr-ml' => \$ftr_ml,
-+ 'groupwise' => \$gw,
-+ 'help|h' => \$_t2,
-+ 'i=s' => \$ifile,
-+ 'k' => \$kamm,
-+ 'kminl=i' => \$_t3,
-+ 'kmaxl=i' => \$_t4,
-+ 'kdiff=i' => \$_t5,
-+ 'L=s' => \$footers,
-+ 'l' => \$ml,
-+ 'lax-security' => \$lax,
-+ 'locale=s' => \$locale,
-+ 'max-lines=i' => \$maxlines,
-+ 'ms-smart' => \$ms_smart,
-+ 'mua|M=s' => \$_t7,
-+ 'm' => \$ms,
-+ 'o=s' => \$ofile,
-+ 'P=s' => \$boun,
-+ 'p:s' => \$_t8,
-+ 'pgp-short' => \$pgpshort,
-+ 'pgp-move' => \$pgpmove,
-+ 'pgp-move-vrf' => \$pgpmovevrf,
-+ 'r' => \$hdrs,
-+ 'S:i' => \$_t6,
-+ 's' => \$sig,
-+ 'sigsmax:i' => \$_ta,
-+ 'spass' => \$spass,
-+ 't' => \$trad,
-+ 'version|v' => \$_tb,
-+ 'w' => \$trsp
-+ )) {
-+ help();
-+}
-
-- if ($mua eq 'mutt') {
-- # mutt still displays the message when ^C'ing pgp verification:
-- $SIG{'INT'} = 'sigint_handler';
-- }
-+# clean up temp vals:
-+if (defined $_t1) {
-+ if ($_t1 !~ /^(?:(\d+)(?:,(\d+))?)?$/) { help(); }
-+ $bigqn = $1?$1:30;
-+ $bigqx = $2?$2:10;
-+ if ($bigqn<=0 || $bigqx<=0 || $bigqn<=$bigqx) { help(); }
-+}
-+if (defined $_t2) { help(); }
-+if (defined $_t3) { $kminl = $_t3; $kamm = 1; }
-+if (defined $_t4) { $kmaxl = $_t4; $kamm = 1; }
-+if (defined $_t5) { $kdiff = $_t5; $kamm = 1; }
-+if (defined $_t6) { $lsig = $_t6 ? $_t6 : $maxsig; }
-+if (defined $_t7) {
-+ $mua = lc($_t7);
-+ # mutt still displays the message when ^C'ing pgp verification:
-+ if ($mua eq 'mutt') { $SIG{'INT'} = 'sigint_handler'; }
-+}
-+if (defined $_t8) { $mda = $_t8 ? $_t8 : '1'; }
-+if (defined $_t9) {
-+ $check = 1;
-+ while ($_t9 && $_t9 =~ /^([^,\s]+)(?:,(\S+))?$/) {
-+ my $foo = $1;
-+ $_t9 = $2;
-+ if ($foo =~ /^ratio(?:=(0?\.\d+))?$/) { $check_ratio = $1?$1:0.75; }
- }
-- elsif ($opt eq 'o') { $ofile = $val; }
-- elsif ($opt eq 'P') { $boun = $val; }
-- elsif ($opt eq 'p') { $mda = $val ? $val : '1'; }
-- elsif ($opt eq 'pgp-short') { $pgpshort = 1; }
-- elsif ($opt eq 'pgp-move') { $pgpmove = 1; }
-- elsif ($opt eq 'pgp-move-vrf') { $pgpmovevrf = 1; }
-- elsif ($opt eq 'r') { $hdrs = 1; }
-- elsif ($opt eq 'S') { $lsig = $val ? $val : $maxsig; }
-- elsif ($opt eq 's') { $sig = 1; }
-- elsif ($opt eq 'sigsmax') { $sign = $val ? $val : undef; }
-- elsif ($opt eq 'spass') { $spass = 1; }
-- elsif ($opt eq 't') { $trad = 1; }
-- elsif ($opt eq 'v') { version(); }
-- elsif ($opt eq 'w') { $trsp = 1; }
-- else { help(); }
- }
--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(); }
--
-+if (defined $_ta) { $sign = $_ta ? $_ta : undef; }
-+if (defined $_tb) { version(); }
-+if ($ms_smart) { $ms = 1; }
-
- if ($mua eq 'mutt') {
- if (defined $locale && $locale ne '' && $locale ne 'C' && $locale ne 'POSIX') {
-@@ -1058,6 +1057,13 @@
-
- }
- elsif ($ms_smart || $pgpshort || $pgpmove || $pgpmovevrf) { help(); }
-+
-+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(); }
-
-
- # Read message:
--- /dev/null
+--- t-prot 2010-02-11 11:41:15.000000000 +0100
++++ t-prot-m1512 2010-02-11 11:48:49.000000000 +0100
+@@ -32,7 +32,7 @@
+
+ $mutt_attachment $mutt_contenttype $mutt_pgpsigned $mutt_beginsigned
+ $mutt_pgpclearsigned $mutt_pgpclearsigstart $mutt_pgpencrypted
+- $mutt_pgpoutstart $mutt_pgpoutend
++ $mutt_pgpoutstart $mutt_pgpoutend $mutt_ssloutstart $mutt_ssloutend
+ );
+
+
+@@ -71,6 +71,8 @@
+ $mutt_pgpencrypted = '[-- End of PGP/MIME encrypted data --]';
+ $mutt_pgpoutstart = '[-- PGP output follows (current time:';
+ $mutt_pgpoutend = '[-- End of PGP output --]';
++$mutt_ssloutstart = '[-- OpenSSL output follows';
++$mutt_ssloutend = '[-- End of OpenSSL output --]';
+
+ # set the defaults to the C locale
+ $gpg_WARNING = 'WARNING: ';
+@@ -342,7 +344,7 @@
+ for (my $x=0; $x<scalar(@$L); $x++) {
+ if ($$V[$x]) { next; }
+
+- if ($$L[$x]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E)/o)
++ if ($$L[$x]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E|\Q$mutt_ssloutstart\E)/o)
+ {
+ my $from;
+ for (my $m=0; $m<scalar(@$H); $m++) {
+@@ -368,7 +370,7 @@
+ $i--;
+ }
+ }
+- elsif ($$L[$i]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutend\E)/o) {
++ elsif ($$L[$i]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutend\E|\Q$mutt_ssloutend\E)/o) {
+ if ($pgpmove ||
+ ($pgpmovevrf && (!$sigint) && verified($L, $x+1, $i)))
+ {
+@@ -698,7 +700,7 @@
+ 'Forwarded message',
+ 'Weitergeleitete Nachricht / Forwarded Message');
+ my $k = 0; # any text above?
+- my $tmp = 0; # flagged if inside PGP output
++ my $tmp = 0; # flagged if inside PGP or SSL output
+
+ DONE: for ($x=0; $x<scalar(@$lines); $x++) {
+ if (!$vrb[$x]) {
+@@ -726,9 +728,11 @@
+ ((!$spass) || index($$lines[$x], $spass_prefix)!=0))
+ {
+ if ($mua eq 'mutt' && (!$tmp) &&
+- $$lines[$x] =~
+- /^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E)/o) {
+- $tmp = 1;
++ ($$lines[$x] =~
++ /^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutstart\E)/o ||
++ $$lines[$x] =~
++ /^(?:\e[^\a]+\a)?(?:\Q$mutt_ssloutstart\E)/o)) {
++ $tmp = 1;
+ } elsif ($mua eq 'mutt' && $tmp &&
+ ($$lines[$x] =~
+ /^(?:\e[^\a]+\a)?(?:\Q$mutt_beginsigned\E)/o ||
+@@ -1004,8 +1008,8 @@
+ Locale::gettext::gettext("[-- Type: %s/%s, Encoding: %s, Size: %s --]\n") =~
+ m/^([^%]*)/;
+ ($mutt_pgpsigned) =
+- Locale::gettext::gettext("[-- End of signed data --]\n") =~
+- m/^(.*)\n/m;
++ Locale::gettext::gettext("\n[-- End of signed data --]\n") =~
++ m/^\n*(.*)\n/m;
+ ($mutt_beginsigned) =
+ Locale::gettext::gettext("[-- The following data is signed --]\n\n") =~
+ m/^(.*)\n/m;
+@@ -1013,16 +1017,24 @@
+ Locale::gettext::gettext("[-- END PGP SIGNED MESSAGE --]\n") =~
+ m/^(.*)\n/m;
+ ($mutt_pgpclearsigstart) =
+- Locale::gettext::gettext("[-- BEGIN PGP SIGNED MESSAGE --]\n") =~
++ Locale::gettext::gettext("[-- BEGIN PGP SIGNED MESSAGE --]\n\n") =~
+ m/^(.*)\n/m;
+ ($mutt_pgpencrypted) =
+ Locale::gettext::gettext("[-- End of PGP/MIME encrypted data --]\n") =~
+ m/^(.*)\n/m;
+ ($mutt_pgpoutstart) =
+- Locale::gettext::gettext("[-- PGP output follows (current time: %c) --]\n") =~
+- m/^([^%]*)/;
++ Locale::gettext::gettext("[-- %s output follows%s --]\n") =~
++ m/^(.*)%s/;
++ $mutt_pgpoutstart =~ s/%s/PGP/;
+ ($mutt_pgpoutend) =
+- Locale::gettext::gettext("[-- End of PGP output --]\n") =~
++ Locale::gettext::gettext("[-- End of PGP output --]\n\n") =~
++ m/^(.*)\n/m;
++ ($mutt_ssloutstart) =
++ Locale::gettext::gettext("[-- %s output follows%s --]\n") =~
++ m/^(.*)%s/;
++ $mutt_ssloutstart =~ s/%s/OpenSSL/;
++ ($mutt_ssloutend) =
++ Locale::gettext::gettext("[-- End of OpenSSL output --]\n\n") =~
+ m/^(.*)\n/m;
+
+ Locale::gettext::textdomain('gnupg');
--- /dev/null
+--- t-prot 2010-02-11 12:10:47.000000000 +0100
++++ t-prot-gol 2010-02-11 12:13:49.000000000 +0100
+@@ -4,7 +4,7 @@
+ require 5.006;
+ use strict;
+ use Fcntl qw(O_EXCL O_WRONLY O_CREAT);
+-use Getopt::Mixed qw(nextOption);
++use Getopt::Long qw(:config gnu_getopt no_ignore_case);
+ use constant VER => '2.14';
+ use constant REV => '';
+ use constant REL => q$Revision: 1.280 $=~m/(\d+(?:\.\d+)+)/;
+@@ -913,84 +913,83 @@
+ (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
+
++# temp vals:
++my ($_t1, $_t2, $_t3, $_t4, $_t5, $_t6, $_t7, $_t8, $_t9, $_ta, $_tb) = undef;
++
+ # 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 body check:s debug>d diff ftr-ad ftr-ml groupwise'.
+- ' help>h kminl=i kmaxl=i kdiff=i lax-security locale=s max-lines=i'.
+- ' 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; }
+- elsif ($opt eq 'bigq') {
+- if ($val !~ /^(?:(\d+)(?:,(\d+))?)?$/) { help(); }
+- $bigqn = $1?$1:30;
+- $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;
+- while ($val && $val =~ /^([^,\s]+)(?:,(\S+))?$/) {
+- my $foo = $1;
+- $val = $2;
+-
+- if ($foo =~ /^ratio(?:=(0?\.\d+))?$/) {
+- $check_ratio = $1?$1:0.75;
+- }
+- }
+- }
+- elsif ($opt eq 'd') { $sysl = 1; }
+- elsif ($opt eq 'diff') { $diff = 1; }
+- elsif ($opt eq 'e') { $elli = 1; }
+- elsif ($opt eq 'ftr-ad') { $ftr_ad = 1; $ad = 1; }
+- elsif ($opt eq 'ftr-ml') { $ftr_ml = 1; $ml = 1; }
+- elsif ($opt eq 'groupwise') { $gw = 1; }
+- elsif ($opt eq 'i') { $ifile = $val; }
+- elsif ($opt eq 'k') { $kamm = 1; }
+- elsif ($opt eq 'kminl') { $kminl = $val; $kamm = 1; }
+- elsif ($opt eq 'kmaxl') { $kmaxl = $val; $kamm = 1; }
+- elsif ($opt eq 'kdiff') { $kdiff = $val; $kamm = 1; }
+- elsif ($opt eq 'L') { $footers = $val; }
+- elsif ($opt eq 'l') { $ml = 1; }
+- elsif ($opt eq 'lax-security') { $lax = 1; }
+- elsif ($opt eq 'locale') { $locale = $val; }
+- elsif ($opt eq 'm') { $ms = 1; }
+- elsif ($opt eq 'max-lines') { $maxlines = $val; }
+- elsif ($opt eq 'ms-smart') { $ms_smart = 1; $ms = 1; }
+- elsif ($opt eq 'M') {
+- $mua = lc($val);
++if (!Getopt::Long::GetOptions(
++ 'a' => \$ad,
++ 'A=s' => \$ads,
++ 'bigq:s' => \$_t1,
++ 'c' => \$cr,
++ 'check:s' => \$_t9,
++ 'debug|d' => \$sysl,
++ 'diff' => \$diff,
++ 'e' => \$elli,
++ 'ftr-ad' => \$ftr_ad,
++ 'ftr-ml' => \$ftr_ml,
++ 'groupwise' => \$gw,
++ 'help|h' => \$_t2,
++ 'i=s' => \$ifile,
++ 'k' => \$kamm,
++ 'kminl=i' => \$_t3,
++ 'kmaxl=i' => \$_t4,
++ 'kdiff=i' => \$_t5,
++ 'L=s' => \$footers,
++ 'l' => \$ml,
++ 'lax-security' => \$lax,
++ 'locale=s' => \$locale,
++ 'max-lines=i' => \$maxlines,
++ 'ms-smart' => \$ms_smart,
++ 'mua|M=s' => \$_t7,
++ 'm' => \$ms,
++ 'o=s' => \$ofile,
++ 'P=s' => \$boun,
++ 'p:s' => \$_t8,
++ 'pgp-short' => \$pgpshort,
++ 'pgp-move' => \$pgpmove,
++ 'pgp-move-vrf' => \$pgpmovevrf,
++ 'r' => \$hdrs,
++ 'S:i' => \$_t6,
++ 's' => \$sig,
++ 'sigsmax:i' => \$_ta,
++ 'spass' => \$spass,
++ 't' => \$trad,
++ 'version|v' => \$_tb,
++ 'w' => \$trsp
++ )) {
++ help();
++}
+
+- if ($mua eq 'mutt') {
+- # mutt still displays the message when ^C'ing pgp verification:
+- $SIG{'INT'} = 'sigint_handler';
+- }
++# clean up temp vals:
++if (defined $_t1) {
++ if ($_t1 !~ /^(?:(\d+)(?:,(\d+))?)?$/) { help(); }
++ $bigqn = $1?$1:30;
++ $bigqx = $2?$2:10;
++ if ($bigqn<=0 || $bigqx<=0 || $bigqn<=$bigqx) { help(); }
++}
++if (defined $_t2) { help(); }
++if (defined $_t3) { $kminl = $_t3; $kamm = 1; }
++if (defined $_t4) { $kmaxl = $_t4; $kamm = 1; }
++if (defined $_t5) { $kdiff = $_t5; $kamm = 1; }
++if (defined $_t6) { $lsig = $_t6 ? $_t6 : $maxsig; }
++if (defined $_t7) {
++ $mua = lc($_t7);
++ # mutt still displays the message when ^C'ing pgp verification:
++ if ($mua eq 'mutt') { $SIG{'INT'} = 'sigint_handler'; }
++}
++if (defined $_t8) { $mda = $_t8 ? $_t8 : '1'; }
++if (defined $_t9) {
++ $check = 1;
++ while ($_t9 && $_t9 =~ /^([^,\s]+)(?:,(\S+))?$/) {
++ my $foo = $1;
++ $_t9 = $2;
++ if ($foo =~ /^ratio(?:=(0?\.\d+))?$/) { $check_ratio = $1?$1:0.75; }
+ }
+- elsif ($opt eq 'o') { $ofile = $val; }
+- elsif ($opt eq 'P') { $boun = $val; }
+- elsif ($opt eq 'p') { $mda = $val ? $val : '1'; }
+- elsif ($opt eq 'pgp-short') { $pgpshort = 1; }
+- elsif ($opt eq 'pgp-move') { $pgpmove = 1; }
+- elsif ($opt eq 'pgp-move-vrf') { $pgpmovevrf = 1; }
+- elsif ($opt eq 'r') { $hdrs = 1; }
+- elsif ($opt eq 'S') { $lsig = $val ? $val : $maxsig; }
+- elsif ($opt eq 's') { $sig = 1; }
+- elsif ($opt eq 'sigsmax') { $sign = $val ? $val : undef; }
+- elsif ($opt eq 'spass') { $spass = 1; }
+- elsif ($opt eq 't') { $trad = 1; }
+- elsif ($opt eq 'v') { version(); }
+- elsif ($opt eq 'w') { $trsp = 1; }
+- else { help(); }
+ }
+-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(); }
+-
++if (defined $_ta) { $sign = $_ta ? $_ta : undef; }
++if (defined $_tb) { version(); }
++if ($ms_smart) { $ms = 1; }
+
+ if ($mua eq 'mutt') {
+ if (defined $locale && $locale ne '' && $locale ne 'C' && $locale ne 'POSIX') {
+@@ -1055,6 +1054,13 @@
+
+ }
+ elsif ($ms_smart || $pgpshort || $pgpmove || $pgpmovevrf) { help(); }
++
++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(); }
+
+
+ # Read message:
#!/usr/bin/perl -w
-# $Id: t-prot,v 1.277 2010/02/06 03:29:23 jochen Exp $
+# $Id: t-prot,v 1.280 2010/02/11 11:10:47 jochen Exp $
require 5.006;
use strict;
use Fcntl qw(O_EXCL O_WRONLY O_CREAT);
use Getopt::Mixed qw(nextOption);
-use constant VER => '2.13';
+use constant VER => '2.14';
use constant REV => '';
-use constant REL => q$Revision: 1.277 $=~m/(\d+(?:\.\d+)+)/;
+use constant REL => q$Revision: 1.280 $=~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';
--pgp-move-vrf move pgp output if verified and good; requires -Mmutt
--pgp-short hide non-relevant pgp key uids; requires -Mmutt
-r delete mail header lines
- -S[=n] supress signatures with more than n lines;
- default is $maxsig if n not specified
+ -S[=n] supress signatures with more than n lines (default $maxsig)
-s delete signature
--sigsmax[=n] max number of sigs tolerated, no value for unlimited
--spass enable SpamAssassin workaround
my $uid = 1;
for (my $i=$x+1; $i<scalar(@$L); $i++) {
- if ($pgpshort && index($$L[$i], "gpg: $gpg_aka")==0)
- { $uid++; }
-
- if ($pgpshort && $uid>1 &&
- index($$L[$i], "gpg: $gpg_aka")==0 &&
- index($$L[$i], $from)<0)
- {
- splice(@$L, $i, 1);
- splice(@$V, $i, 1);
- $i--;
+ if ($pgpshort && index($$L[$i], "gpg: $gpg_aka")==0) {
+ $uid++;
+
+ if ($uid>1 && index($$L[$i], $from)<0) {
+ splice(@$L, $i, 1);
+ splice(@$V, $i, 1);
+ $i--;
+ }
}
- elsif ($$L[$i]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutend\E)/o)
- {
+ elsif ($$L[$i]=~/^(?:\e[^\a]+\a)?(?:\Q$mutt_pgpoutend\E)/o) {
if ($pgpmove ||
($pgpmovevrf && (!$sigint) && verified($L, $x+1, $i)))
{
-.\" $Id: t-prot.1,v 1.148 2010/02/07 14:31:14 jochen Exp $
+.\" $Id: t-prot.1,v 1.151 2010/02/07 22:10:06 jochen Exp $
.\"
.TH T-PROT "1" "February 2010" "T-PROT"
.SH NAME
.BI "t\-prot [" OPTIONS "]..."
.SH DESCRIPTION
.PP
-This program is a filter to improve the readability of
+This program is a filter to improve the readability of internet
messages (emails and usenet posts) by *hiding* some annoying parts,
e.g. mailing list footers, signatures, and TOFU (see definition below),
as well as squeezing sequences of blank lines or punctuation.
+The program also detects TOFU or a high quoting ratio in a message (so
+you may take appropriate action, e.g. when submitting messages to a mailing
+list or a news server).
.br
The filter is written in Perl and relies on input to be a single
message conforming to RFC 822 or its successors, RFC 2822 and RFC 5322.
.PP
For easy usage, you can include the file muttrc.t\-prot in your
~/.muttrc. Also coming with the t-prot package is the example S-Lang
-macro t\-prot.sl for using t-prot from within slrn.
+macro t\-prot.sl for using t-prot from within slrn. There is a
+proof\-of\-concept filter for INN2, which you will have to adapt to
+the needs of the news site you host (please see the file for details).
.SH OPTIONS
.TP
.BR "\-A" =DIRECTORY
Defaults are 30 for n and 10 for x.
.TP
.B "\-\-body"
-Input consists just of the message's body. There are no RFC 2822 header
+Input consists just of the message's body. There are no RFC 5322 header
lines.
.IP
.IR NOTE :