diff --git a/README.md b/README.md index d922040..c36197c 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,18 @@ Posting filter to add Cancel-Lock and Cancel-Key Copy to `/etc/news/filter/cleanfeed/etc/cleanfeed.local`. ------------------------------------------------------------ + +## Other INN-adjacent scripts + +### contrib/suck-postfilter.pl + +Postfilter for rpost to remove folded headers like `Injection-Info` +before posting, written for the Debian *suck* package (and an INN +with `sm`). + +Copy somewhere, e.g. to `/usr/lib/suck/postfilter.pl`, and add a +matching `postfilter` option to `/etc/suck/get-news.conf`, like + + postfilter: /usr/lib/suck/postfilter.pl + +------------------------------------------------------------ diff --git a/contrib/suck-postfilter.pl b/contrib/suck-postfilter.pl new file mode 100644 index 0000000..fcb1ab4 --- /dev/null +++ b/contrib/suck-postfilter.pl @@ -0,0 +1,56 @@ +#! /usr/bin/perl -w +# +# postfilter for rpost, to be called from get-news +# +# add "postfilter: /path/to/this/script" to get-news.conf + +use strict; + +# set regexp for offending headers +my $headerexp = 'NNTP-Posting-Host|NNTP-Posting-Date|X-Complaints-To|Xref|X-Trace|X-Server-Date|Path|Injection-Info'; +# debug switch +my $debug = 0; + +# read command line arguments +my $infile = $ARGV[0]; # storage token +my $outfile = $ARGV[1]; + +$infile =~ s/^[^@]*//; + +if (!$outfile) { + print "Usage: $0 infile outfile\n"; + exit 2; +} + +# open file handles +open INPUT, "/usr/lib/news/bin/sm $infile |" or return $infile; +open OUTPUT, ">${outfile}" or die "Can't create ${outfile}"; + +# remove offending lines +my $found = 0; +while ( $line = ) { + if($line =~ /^$headerexp: /) { + $found = 1; + print "!! $line" if $debug; + } elsif ($found && $line =~ /^[ \t]+/) { + # continuation line(s) + print "!> $line" if $debug; + } else { + $found = 0; + # write out to file + print OUTPUT $line; + print $line if $debug; + } + # stop parsing after end-of-header + last if ($line =~ /^$/); +} +while ( $line = ) { + print OUTPUT $line; + print $line if $debug; +} + +# close file handles +close INPUT; +close OUTPUT; + +exit;