diff options
author | Eric Wong <e@80x24.org> | 2016-06-15 00:14:27 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-06-15 00:15:11 +0000 |
commit | 61f05bf5869c3f471a16926b1a837ab0d95fb095 (patch) | |
tree | 41841dbde442f896ca5ba0495284cbbd6de784ac /lib/PublicInbox/Filter/Vger.pm | |
parent | 41aa4756879765d0c6d4d6e8754e0037b1a56fcc (diff) | |
download | public-inbox-61f05bf5869c3f471a16926b1a837ab0d95fb095.tar.gz |
This filter API should be independent of Email::Filter and hopefully less intrusive to long running processes.
Diffstat (limited to 'lib/PublicInbox/Filter/Vger.pm')
-rw-r--r-- | lib/PublicInbox/Filter/Vger.pm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/PublicInbox/Filter/Vger.pm b/lib/PublicInbox/Filter/Vger.pm new file mode 100644 index 00000000..9498081a --- /dev/null +++ b/lib/PublicInbox/Filter/Vger.pm @@ -0,0 +1,33 @@ +# Copyright (C) 2016 all contributors <meta@public-inbox.org> +# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt> + +# Filter for vger.kernel.org list trailer +package PublicInbox::Filter::Vger; +use base qw(PublicInbox::Filter::Base); +use strict; +use warnings; + +my $l0 = qr/-+/; # older messages only had one '-' +my $l1 = + qr/To unsubscribe from this list: send the line "unsubscribe [\w-]+" in/; +my $l2 = qr/the body of a message to majordomo\@vger\.kernel\.org/; +my $l3 = + qr!More majordomo info at +http://vger\.kernel\.org/majordomo-info\.html!; + +# only LKML had this, and LKML nowadays has no list trailer since Jan 2016 +my $l4 = qr!Please read the FAQ at +http://www\.tux\.org/lkml/!; + +sub delivery { + my ($self, $mime) = @_; + my $s = $mime->as_string; + + # the vger appender seems to only work on the raw string, + # so in multipart (e.g. GPG-signed) messages, the list trailer + # becomes invisible to MIME-aware email clients. + if ($s =~ s/$l0\n$l1\n$l2\n$l3\n($l4\n)?\z//os) { + $mime = Email::MIME->new(\$s); + } + $self->ACCEPT($mime); +} + +1; |