From 7391d6667df5e3254d7fa2a8677b70b853d32305 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 27 Jun 2026 10:12:43 +0200 Subject: [PATCH] Add suck-postfilter. Signed-off-by: Thomas Hochstein --- README.md | 11 ++++++++++ suck-postfilter.pl | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 suck-postfilter.pl diff --git a/README.md b/README.md index ffce066..c39269f 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,14 @@ check whether a given Cancel-Lock and Cancel-Key match. ## mew `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 diff --git a/suck-postfilter.pl b/suck-postfilter.pl new file mode 100644 index 0000000..811a2b6 --- /dev/null +++ b/suck-postfilter.pl @@ -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 = ) { + 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 = ) { + print OUTPUT $line; + print $line if $debug; +} + +# close file handles +close INPUT; +close OUTPUT; + +exit;