diff options
author | Eric Wong <e@yhbt.net> | 2020-05-07 21:05:50 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-05-09 08:59:10 +0000 |
commit | 46742d95647c7a80cb2f60d5c134717dd91e22e2 (patch) | |
tree | 43b6ef4aebba979e48eb9143cd491f1a5b3f7eea /script | |
parent | 3b1b7abf814dbc7f2a737b2ca0e12b0fa518ff44 (diff) | |
download | public-inbox-46742d95647c7a80cb2f60d5c134717dd91e22e2.tar.gz |
PublicInbox::Eml has enough functionality to replace the Email::MIME-based PublicInbox::MIME.
Diffstat (limited to 'script')
-rwxr-xr-x | script/public-inbox-edit | 8 | ||||
-rw-r--r-- | script/public-inbox-learn | 4 | ||||
-rwxr-xr-x | script/public-inbox-mda | 16 | ||||
-rwxr-xr-x | script/public-inbox-purge | 4 |
4 files changed, 16 insertions, 16 deletions
diff --git a/script/public-inbox-edit b/script/public-inbox-edit index 42f914a8..e895a228 100755 --- a/script/public-inbox-edit +++ b/script/public-inbox-edit @@ -12,7 +12,7 @@ use File::Temp 0.19 (); # 0.19 for TMPDIR use PublicInbox::ContentId qw(content_id); use PublicInbox::MID qw(mid_clean mids); PublicInbox::Admin::check_require('-index'); -use PublicInbox::MIME; +use PublicInbox::Eml; use PublicInbox::InboxWritable; use PublicInbox::Import; @@ -52,7 +52,7 @@ sub find_mid ($$$) { my ($id, $prev); while (my $smsg = $over->next_by_mid($mid, \$id, \$prev)) { my $ref = $ibx->msg_by_smsg($smsg); - my $mime = PublicInbox::MIME->new($ref); + my $mime = PublicInbox::Eml->new($ref); my $cid = content_id($mime); my $tuple = [ $ibx, $smsg ]; push @{$found->{$cid} ||= []}, $tuple @@ -205,8 +205,8 @@ W: possible message boundary splitting error $new_raw =~ s/^>(>*From )/$1/gm; } - my $new_mime = PublicInbox::MIME->new(\$new_raw); - my $old_mime = PublicInbox::MIME->new($old_raw); + my $new_mime = PublicInbox::Eml->new(\$new_raw); + my $old_mime = PublicInbox::Eml->new($old_raw); # make sure we don't compare unwanted headers, since mutt adds # Content-Length, Status, and Lines headers: diff --git a/script/public-inbox-learn b/script/public-inbox-learn index 4c10b68b..a33d813a 100644 --- a/script/public-inbox-learn +++ b/script/public-inbox-learn @@ -9,7 +9,7 @@ use strict; use warnings; use PublicInbox::Config; use PublicInbox::InboxWritable; -use PublicInbox::MIME; +use PublicInbox::Eml; use PublicInbox::Address; use PublicInbox::Spamcheck::Spamc; my $train = shift or die "usage: $usage\n"; @@ -20,7 +20,7 @@ if ($train !~ /\A(?:ham|spam|rm)\z/) { my $spamc = PublicInbox::Spamcheck::Spamc->new; my $pi_config = PublicInbox::Config->new; my $err; -my $mime = PublicInbox::MIME->new(do{ +my $mime = PublicInbox::Eml->new(do{ local $/; my $data = <STDIN>; $data =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s; diff --git a/script/public-inbox-mda b/script/public-inbox-mda index 54d0af01..42d0e00c 100755 --- a/script/public-inbox-mda +++ b/script/public-inbox-mda @@ -15,8 +15,7 @@ my $do_exit = sub { exit $code; }; -use Email::Simple; -use PublicInbox::MIME; +use PublicInbox::Eml; use PublicInbox::MDA; use PublicInbox::Config; use PublicInbox::Emergency; @@ -32,7 +31,7 @@ $ems = PublicInbox::Emergency->new($emergency); my $str = do { local $/; <STDIN> }; $str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s; $ems->prepare(\$str); -my $simple = Email::Simple->new(\$str); +my $eml = PublicInbox::Eml->new(\$str); my $config = PublicInbox::Config->new; my $key = 'publicinboxmda.spamcheck'; my $default = 'PublicInbox::Spamcheck::Spamc'; @@ -44,7 +43,7 @@ if (defined $recipient) { push @$dests, $ibx if $ibx; } if (!scalar(@$dests)) { - $dests = PublicInbox::MDA->inboxes_for_list_id($config, $simple); + $dests = PublicInbox::MDA->inboxes_for_list_id($config, $eml); if (!scalar(@$dests) && !defined($recipient)) { die "ORIGINAL_RECIPIENT not defined in ENV\n"; } @@ -61,7 +60,7 @@ my $err; 0; # pre-check, MDA has stricter rules than an importer might; } elsif ($precheck) { - !!PublicInbox::MDA->precheck($simple, $ibx->{address}); + !!PublicInbox::MDA->precheck($eml, $ibx->{address}); } else { 1; } @@ -69,7 +68,7 @@ my $err; $do_exit->(67) if $err && scalar(@$dests) == 0; -$simple = undef; +$eml = undef; my $spam_ok; if ($spamc) { $str = ''; @@ -101,9 +100,10 @@ my @rejects; for my $ibx (@$dests) { mda_filter_adjust($ibx); my $filter = $ibx->filter; - my $mime = PublicInbox::MIME->new($str); + my $mime = PublicInbox::Eml->new($str); my $ret = $filter->delivery($mime); - if (ref($ret) && $ret->isa('Email::MIME')) { # filter altered message + if (ref($ret) && ($ret->isa('PublicInbox::Eml') || + $ret->isa('Email::MIME'))) { # filter altered message $mime = $ret; } elsif ($ret == PublicInbox::Filter::Base::IGNORE) { next; # nothing, keep looping diff --git a/script/public-inbox-purge b/script/public-inbox-purge index 8301b06d..82a63b80 100755 --- a/script/public-inbox-purge +++ b/script/public-inbox-purge @@ -10,7 +10,7 @@ use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); use PublicInbox::AdminEdit; PublicInbox::Admin::check_require('-index'); use PublicInbox::Filter::Base qw(REJECT); -use PublicInbox::MIME; +use PublicInbox::Eml; require PublicInbox::V2Writable; my $usage = "$0 [--all] [INBOX_DIRS] </path/to/message"; @@ -26,7 +26,7 @@ $data =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s; my $n_purged = 0; foreach my $ibx (@ibxs) { - my $mime = PublicInbox::MIME->new($data); + my $mime = PublicInbox::Eml->new($data); my $v2w = PublicInbox::V2Writable->new($ibx, 0); my $commits = $v2w->purge($mime) || []; |