From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/2] filter: split out scrub method from delivery
Date: Fri, 17 Jun 2016 00:41:27 +0000 [thread overview]
Message-ID: <20160617004128.1037-2-e@80x24.org> (raw)
In-Reply-To: <20160617004128.1037-1-e@80x24.org>
We will scrub for importing archives, so ensure it is usable
outside of the delivery routine.
---
lib/PublicInbox/Filter/Base.pm | 9 ++++++++-
lib/PublicInbox/Filter/Vger.pm | 7 ++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/Filter/Base.pm b/lib/PublicInbox/Filter/Base.pm
index 0991e87..37f1ee7 100644
--- a/lib/PublicInbox/Filter/Base.pm
+++ b/lib/PublicInbox/Filter/Base.pm
@@ -62,6 +62,13 @@ sub reject ($$) {
sub err ($) { $_[0]->{err} }
+# by default, scrub is a no-op, see PublicInbox::Filter::Vger::scrub
+# for an example of the override
+sub scrub {
+ my ($self, $mime) = @_;
+ $self->ACCEPT($mime);
+}
+
# for MDA
sub delivery {
my ($self, $mime) = @_;
@@ -94,7 +101,7 @@ sub delivery {
push @r, 'Rejected suffixes(s): '.join(', ', sort keys %sfx);
}
- @r ? $self->reject(join("\n", @r)) : $self->ACCEPT;
+ @r ? $self->reject(join("\n", @r)) : $self->scrub($mime);
}
1;
diff --git a/lib/PublicInbox/Filter/Vger.pm b/lib/PublicInbox/Filter/Vger.pm
index 9498081..2ffed18 100644
--- a/lib/PublicInbox/Filter/Vger.pm
+++ b/lib/PublicInbox/Filter/Vger.pm
@@ -17,7 +17,7 @@ my $l3 =
# 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 {
+sub scrub {
my ($self, $mime) = @_;
my $s = $mime->as_string;
@@ -30,4 +30,9 @@ sub delivery {
$self->ACCEPT($mime);
}
+sub delivery {
+ my ($self, $mime) = @_;
+ $self->scrub($mime);
+}
+
1;
next prev parent reply other threads:[~2016-06-17 0:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 0:41 [PATCH 0/2] introduce public-inbox-watch Eric Wong
2016-06-17 0:41 ` Eric Wong [this message]
2016-06-17 0:41 ` [PATCH 2/2] watch: introduce watch directive Eric Wong
2016-06-17 1:25 ` [PATCH 3/2] watch: quiet down rejected header matches Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160617004128.1037-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).