user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 0/9] big mda filter changes
@ 2016-06-15  0:37  7% Eric Wong
  2016-06-15  0:37  6% ` [PATCH 6/9] mda: precheck no longer depends on Email::Filter Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2016-06-15  0:37 UTC (permalink / raw)
  To: meta

Eric Wong (9):
      drop dependency on File::Path::Expand
      t/feed.t: make IPC::Run usage optional
      learn: remove IPC::Run dependency
      t/mda.t: remove senseless use of Email::Filter
      t/mda: use only Maildir for testing
      mda: precheck no longer depends on Email::Filter
      filter: begin work on a new filter API
      emergency: implement new emergency Maildir delivery
      mda: hook up new filter functionality

 INSTALL                          |   3 -
 Makefile.PL                      |   2 -
 lib/PublicInbox/Config.pm        |   3 +-
 lib/PublicInbox/Emergency.pm     |  96 +++++++++++
 lib/PublicInbox/Filter.pm        | 232 ---------------------------
 lib/PublicInbox/Filter/Base.pm   | 100 ++++++++++++
 lib/PublicInbox/Filter/Mirror.pm |  12 ++
 lib/PublicInbox/Filter/Vger.pm   |  33 ++++
 lib/PublicInbox/MDA.pm           |  11 +-
 script/public-inbox-learn        |  42 +++--
 script/public-inbox-mda          | 135 ++++++++--------
 t/emergency.t                    |  53 ++++++
 t/feed.t                         |  18 +--
 t/filter.t                       | 337 ---------------------------------------
 t/filter_base.t                  |  81 ++++++++++
 t/filter_mirror.t                |  40 +++++
 t/filter_vger.t                  |  46 ++++++
 t/mda.t                          |  79 ++-------
 t/precheck.t                     |  14 +-
 19 files changed, 586 insertions(+), 751 deletions(-)

 Note to self: get "git apply" to work on --irreversible-delete patches


^ permalink raw reply	[relevance 7%]

* [PATCH 6/9] mda: precheck no longer depends on Email::Filter
  2016-06-15  0:37  7% [PATCH 0/9] big mda filter changes Eric Wong
@ 2016-06-15  0:37  6% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-06-15  0:37 UTC (permalink / raw)
  To: meta

Email::Filter doesn't offer any functionality we need, here;
and our dependency on Email::Filter will gradually be removed
since it (and Email::LocalDelivery) seem abandoned and we
can have more-fine-grained control by rolling our own Maildir
delivery which can work transactionally.
---
 lib/PublicInbox/MDA.pm  | 11 +++++------
 script/public-inbox-mda |  2 +-
 t/precheck.t            | 14 +++++---------
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm
index 2e6e9ec..0f583e6 100644
--- a/lib/PublicInbox/MDA.pm
+++ b/lib/PublicInbox/MDA.pm
@@ -32,18 +32,17 @@ sub __drop_plus {
 
 # do not allow Bcc, only Cc and To if recipient is set
 sub precheck {
-	my ($klass, $filter, $address) = @_;
-	my Email::Simple $simple = $filter->simple;
+	my ($klass, $simple, $address) = @_;
 	my @mid = $simple->header('Message-ID');
 	return 0 if scalar(@mid) != 1;
 	my $mid = $mid[0];
 	return 0 if (length($mid) > MAX_MID_SIZE);
 	return 0 unless usable_str(length('<m@h>'), $mid) && $mid =~ /\@/;
-	return 0 unless usable_str(length('u@h'), $filter->from);
+	return 0 unless usable_str(length('u@h'), $simple->header("From"));
 	return 0 unless usable_str(length(':o'), $simple->header("Subject"));
 	return 0 unless usable_date($simple->header("Date"));
 	return 0 if length($simple->as_string) > MAX_SIZE;
-	alias_specified($filter, $address);
+	alias_specified($simple, $address);
 }
 
 sub usable_str {
@@ -57,14 +56,14 @@ sub usable_date {
 }
 
 sub alias_specified {
-	my ($filter, $address) = @_;
+	my ($simple, $address) = @_;
 
 	my @address = ref($address) eq 'ARRAY' ? @$address : ($address);
 	my %ok = map {
 		lc(__drop_plus($_)) => 1;
 	} @address;
 
-	foreach my $line ($filter->cc, $filter->to) {
+	foreach my $line ($simple->header('Cc'), $simple->header('To')) {
 		my @addrs = ($line =~ /([^<\s]+\@[^>\s]+)/g);
 		foreach my $addr (@addrs) {
 			if ($ok{lc(__drop_plus($addr))}) {
diff --git a/script/public-inbox-mda b/script/public-inbox-mda
index 84219ac..ff2835d 100755
--- a/script/public-inbox-mda
+++ b/script/public-inbox-mda
@@ -34,7 +34,7 @@ defined $dst or exit(1);
 my $main_repo = $dst->{mainrepo} or exit(1);
 my $filtered; # string dest
 
-if (PublicInbox::MDA->precheck($filter, $dst->{address}) &&
+if (PublicInbox::MDA->precheck($filter->simple, $dst->{address}) &&
     do_spamc($filter->simple, \$filtered)) {
 	# update our message with SA headers (in case our filter rejects it)
 	my $msg = Email::MIME->new(\$filtered);
diff --git a/t/precheck.t b/t/precheck.t
index 3f2c5d5..6c353d8 100644
--- a/t/precheck.t
+++ b/t/precheck.t
@@ -4,28 +4,25 @@ use strict;
 use warnings;
 use Test::More;
 use Email::Simple;
-use Email::Filter;
 use PublicInbox::MDA;
 
 sub do_checks {
 	my ($s) = @_;
 
-	my $f = Email::Filter->new(data => $s->as_string);
-
 	my $recipient = 'foo@example.com';
-	ok(!PublicInbox::MDA->precheck($f, $recipient),
+	ok(!PublicInbox::MDA->precheck($s, $recipient),
 		"wrong ORIGINAL_RECIPIENT rejected");
 
 	$recipient = 'b@example.com';
-	ok(PublicInbox::MDA->precheck($f, $recipient),
+	ok(PublicInbox::MDA->precheck($s, $recipient),
 		"ORIGINAL_RECIPIENT in To: is OK");
 
 	$recipient = 'c@example.com';
-	ok(PublicInbox::MDA->precheck($f, $recipient),
+	ok(PublicInbox::MDA->precheck($s, $recipient),
 		"ORIGINAL_RECIPIENT in Cc: is OK");
 
 	$recipient = [ 'c@example.com', 'd@example.com' ];
-	ok(PublicInbox::MDA->precheck($f, $recipient),
+	ok(PublicInbox::MDA->precheck($s, $recipient),
 		"alias list is OK");
 }
 
@@ -72,8 +69,7 @@ sub do_checks {
 		],
 		body => "hello world\n",
 	);
-	my $f = Email::Filter->new(data => $s->as_string);
-	ok(!PublicInbox::MDA->precheck($f, $recipient),
+	ok(!PublicInbox::MDA->precheck($s, $recipient),
 		"missing From: is rejected");
 }
 

^ permalink raw reply related	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-06-15  0:37  7% [PATCH 0/9] big mda filter changes Eric Wong
2016-06-15  0:37  6% ` [PATCH 6/9] mda: precheck no longer depends on Email::Filter Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).