From 7715c70e5a8667fbd9eade0cffb6ab05a714dd5d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 28 Dec 2018 19:17:36 +0000 Subject: add filter for gmane archives Extracted from import_slrnspool, since some spools get converted to mbox or what not. --- lib/PublicInbox/Filter/Gmane.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/PublicInbox/Filter/Gmane.pm (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/Filter/Gmane.pm b/lib/PublicInbox/Filter/Gmane.pm new file mode 100644 index 00000000..f9042dfc --- /dev/null +++ b/lib/PublicInbox/Filter/Gmane.pm @@ -0,0 +1,41 @@ +# Copyright (C) 2018 all contributors +# License: AGPL-3.0+ + +# Filter for importing some archives from gmane +package PublicInbox::Filter::Gmane; +use base qw(PublicInbox::Filter::Base); +use strict; +use warnings; + +sub scrub { + my ($self, $mime) = @_; + my $hdr = $mime->header_obj; + + # gmane rewrites Received headers, which increases spamminess + # Some older archives set Original-To + foreach my $x (qw(Received To)) { + my @h = $hdr->header_raw("Original-$x"); + if (@h) { + $hdr->header_set($x, @h); + $hdr->header_set("Original-$x"); + } + } + + # Approved triggers for the SA HEADER_SPAM rule, + # X-From is gmane specific + foreach my $drop (qw(Approved X-From)) { + $hdr->header_set($drop); + } + + # appears to be an old gmane bug: + $hdr->header_set('connect()'); + + $self->ACCEPT($mime); +} + +sub delivery { + my ($self, $mime) = @_; + $self->scrub($mime); +} + +1; -- cgit v1.2.3-24-ge0c7