Add suck-postfilter.pl
Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
parent
7fb4c9d347
commit
4fe932925b
2 changed files with 71 additions and 0 deletions
15
README.md
15
README.md
|
|
@ -30,3 +30,18 @@ Posting filter to add Cancel-Lock and Cancel-Key
|
||||||
Copy to `/etc/news/filter/cleanfeed/etc/cleanfeed.local`.
|
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
|
||||||
|
|
||||||
|
------------------------------------------------------------
|
||||||
|
|
|
||||||
56
contrib/suck-postfilter.pl
Normal file
56
contrib/suck-postfilter.pl
Normal file
|
|
@ -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 = <INPUT> ) {
|
||||||
|
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 = <INPUT> ) {
|
||||||
|
print OUTPUT $line;
|
||||||
|
print $line if $debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
# close file handles
|
||||||
|
close INPUT;
|
||||||
|
close OUTPUT;
|
||||||
|
|
||||||
|
exit;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue