1 --- t-prot 2002-03-25 02:15:50.000000000 +0100
2 +++ t-prot-d 2002-03-28 16:27:02.000000000 +0100
4 $EX_OK $EX_USAGE $EX_DATAERR $EX_UNAVAILABLE $EX_BOUNCE
5 $ad $ads $boun $cr $diff $elli $footers $hdrs $indent $lsig $maxsig
6 $mda $ml $ms $mua $ofile $sendmail $sig $sysl $trad $trsp
15 $REL = q$Revision: 1.51 $; chop($REL);
17 # (you might have to adjust those if not using GNU libc)
19 $sendmail = '/usr/sbin/sendmail -oi'; # MTA expecting mail on STDIN
20 $boun = "Blocked by $0: This user does not accept TOFUed email. Please see <http://learn.to/edit_messages/> and <http://www.escape.de/users/tolot/mutt/> for more info. Have a nice day!\n";
21 $ofile = '-'; # use STDOUT if nothing is specified
22 +$dc = 0; # debug dump counter
24 + # this should better be changed by command line for
25 + # confidential messages
26 # end of user adjusted vals
30 -A=DIRECTORY ad footer directory, treat ad footers as signature
31 -c merge multiple blank lines
32 -d, --debug print notice to syslog when bouncing; requires -p
33 + --debugpath=DIR where to dump debug info
34 --diff tolerate diffs appended *after* the signature
35 -e force ellipsis for excessive punctuation
36 -h, --help show this short help and exit
38 # version(): print version info and exit with appropriate exit code
40 print "$0 v$VER$REV ($REL), Jochen Striepe <t-prot\@tolot.escape.de>
41 +This is a debugging version. DO NOT INSTALL THIS VERSION FOR DAILY USE!
42 Get the latest version at <http://www.escape.de/users/tolot/mutt/>\n";
46 +# write useful debugging output
47 +# usage: debug_dump('/tmp/foo', $foo, $bar, @klotz);
49 + if (scalar(@_)<2) { die "bad parameters"; }
51 + if (-l $f) { die "We won't write to $f for security reasons"; }
53 + open(DBG, ">$f") || die "Could not open $f: $!";
66 # remove_footers(): remove any trailing appearance of footers contained
67 # in the given directory.
69 for ($x=0; $x<$#$lines; $x++) { if (@$lines[$x] =~ /^$/) { last; }; }
70 @hdr = @$lines[0..$x];
71 splice(@$lines, 0, $x+1);
72 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
74 # See if we have a multipart content type. If yes, see if it is already
75 # ripped (e.g. by mutt(1)), otherwise only leave the first part if it
80 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
82 # Pipe message/rfc822 parts to another instance of process_msg()
83 # for further processing.
88 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
91 remove_footers($lines, \@ftr, $footers, undef);
92 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
95 remove_footers($lines, \@ads, $ads, undef);
96 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
99 if (scalar(@$lines)) {
104 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
106 # Now care about TOFU.
107 # One common mispractice is M$ style TOFU:
109 $j = scalar(@$lines)-$x;
112 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
114 # Nothing? Then try traditional TOFU:
115 if ($trad && (!$j) && !$vrb[$#$lines]) {
120 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
122 # OK, if we found TOFU, we will leave a message that we were here...
126 push(@$lines, "[---=| TOFU protection by $0: $j lines snipped |=---]\n");
128 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
131 # Care for trailing whitespaces:
133 if (!$vrb[$x]) { $$lines[$x] =~ s/[\ \t]+$//; }
136 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
138 # Care for punctuation abuse:
141 if (!$vrb[$x]) { $$lines[$x] =~ s/([.?!])(\1{2})\1+/$1 . $2/eg; }
144 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
146 # (Nearly) at last care for multiple blank lines. (Do not do this
147 # earlier -- the way it is done right now would screw up the verbatim
152 + debug_dump($debugpath.'_'.$$.'_'.$dc++, @$lines);
154 # Everything changing the body is done now. Time to fix the line count
155 # header so naive clients do not get confused. Just to be sure, append
156 @@ -428,12 +467,13 @@
157 # get command line params:
159 Getopt::Mixed::init('a A=s c d e h i=s L=s l m M=s o=s P=s p=s r S:i'.
160 - ' s t v w debug>d diff help>h mua>M version>v');
161 + ' s t v w debug>d debugpath diff help>h mua>M version>v');
162 while (my ($opt, $val, $pretty) = nextOption()) {
163 if ($opt eq 'a') { $ad = 1; }
164 elsif ($opt eq 'A') { $ads = $val; }
165 elsif ($opt eq 'c') { $cr = 1; }
166 elsif ($opt eq 'd') { $sysl = 1; }
167 + elsif ($opt eq 'debugpath') { $debugpath = $val; }
168 elsif ($opt eq 'diff') { $diff = 1; }
169 elsif ($opt eq 'e') { $elli = 1; }
170 elsif ($opt eq 'i') { $ifile = $val; }
171 @@ -454,17 +494,26 @@
173 Getopt::Mixed::cleanup();
174 if (($ml && $footers eq '')||($ad && $ads eq '')) { help(); }
176 +$debugpath .= '/t-prot-d';
179 open(IN, $ifile) || die "Could not open $ifile: $!";
182 +debug_dump($debugpath.'_'.$$.'_'.$dc++,
184 + "ad=$ad", "ads=$ads", "cr=$cr", "sysl=$sysl", "elli=$elli", "ml=$ml",
185 + "ms=$ms", "mda=$mda", "mua=$mua", "hdrs=$hdrs", "lsig=$lsig", "sig=$sig",
186 + "trad=$trad", "trsp=$trsp", "footers=$footers", "ifile=$ifile",
187 + "ofile=$ofile", "maxsig=$maxsig", "indent=$indent", "sendmail=$sendmail",
189 +debug_dump($debugpath.'_'.$$.'_'.$dc++, @message);
191 # this should be self-explanatory:
192 process_msg(\@message);
194 # Finally, print clean lines:
195 write_msg(($mda?"|$sendmail $mda":">$ofile"), \@message);
196 +debug_dump($debugpath.'_'.$$.'_'.$dc++, @message);