Add suck-postfilter.
Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
parent
db48e5eae2
commit
7391d6667d
2 changed files with 63 additions and 0 deletions
11
README.md
11
README.md
|
|
@ -11,3 +11,14 @@ check whether a given Cancel-Lock and Cancel-Key match.
|
||||||
## mew
|
## mew
|
||||||
|
|
||||||
`mew.pl` will encode or decode MIME encoded words (RFC 2047).
|
`mew.pl` will encode or decode MIME encoded words (RFC 2047).
|
||||||
|
|
||||||
|
## suck-postfilter
|
||||||
|
|
||||||
|
`suck-postfilter` is a drop-in replacement for `/usr/lib/suck/put-news`,
|
||||||
|
part of the Debian `suck` package. `put-news` can't handle multi-line
|
||||||
|
headers like `Injection-Info:`.
|
||||||
|
|
||||||
|
Save to `/usr/lib/suck/` (or anywhere else) and add the new postfilter
|
||||||
|
to `/etc/suck/get-news.conf`:
|
||||||
|
|
||||||
|
postfilter: /usr/lib/suck/suck-postfilter.pl
|
||||||
|
|
|
||||||
52
suck-postfilter.pl
Normal file
52
suck-postfilter.pl
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#! /usr/bin/perl -w
|
||||||
|
|
||||||
|
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 $infile;
|
||||||
|
|
||||||
|
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 ( my $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 ( my $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