* [PATCH 07/13] replace most uses of PublicInbox::MIME with Eml
2020-05-07 21:05 7% [PATCH 00/13] eml: pure-Perl replacement for Email::MIME Eric Wong
@ 2020-05-07 21:05 4% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-05-07 21:05 UTC (permalink / raw)
To: meta
PublicInbox::Eml has enough functionality to replace the
Email::MIME-based PublicInbox::MIME.
---
Documentation/mknews.perl | 4 ++--
lib/PublicInbox/Admin.pm | 2 +-
lib/PublicInbox/Filter/Vger.pm | 4 ++--
lib/PublicInbox/Import.pm | 3 ++-
lib/PublicInbox/Inbox.pm | 4 ++--
lib/PublicInbox/InboxWritable.pm | 4 ++--
lib/PublicInbox/MDA.pm | 1 -
lib/PublicInbox/SearchIdx.pm | 6 +++---
lib/PublicInbox/SearchIdxShard.pm | 3 ++-
lib/PublicInbox/TestCommon.pm | 3 +++
lib/PublicInbox/V2Writable.pm | 17 +++++++++--------
lib/PublicInbox/View.pm | 2 +-
lib/PublicInbox/WWW.pm | 2 +-
lib/PublicInbox/WatchMaildir.pm | 4 ++--
lib/PublicInbox/WwwAttach.pm | 5 ++---
script/public-inbox-edit | 8 ++++----
script/public-inbox-learn | 4 ++--
script/public-inbox-mda | 16 ++++++++--------
script/public-inbox-purge | 4 ++--
t/filter_rubylang.t | 8 ++++----
t/import.t | 2 +-
21 files changed, 55 insertions(+), 51 deletions(-)
diff --git a/Documentation/mknews.perl b/Documentation/mknews.perl
index a9dede00..3bdebfce 100755
--- a/Documentation/mknews.perl
+++ b/Documentation/mknews.perl
@@ -5,7 +5,7 @@
# this uses unstable internal APIs of public-inbox, and this script
# needs to be updated if they change.
use strict;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::View;
use PublicInbox::MsgTime qw(msg_datestamp);
use PublicInbox::MID qw(mids mid_escape);
@@ -76,7 +76,7 @@ sub release2mime {
my ($release, $mtime_ref) = @_;
my $f = "$dir/$release.eml";
open(my $fh, '<', $f) or die "open($f): $!";
- my $mime = PublicInbox::MIME->new(do { local $/; <$fh> });
+ my $mime = PublicInbox::Eml->new(\(do { local $/; <$fh> }));
# Documentation/include.mk relies on mtimes of each .eml file
# to trigger rebuild, so make sure we sync the mtime to the Date:
# header in the .eml
diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm
index 62ddbe82..2c8d191a 100644
--- a/lib/PublicInbox/Admin.pm
+++ b/lib/PublicInbox/Admin.pm
@@ -122,7 +122,7 @@ EOF
}
# TODO: make Devel::Peek optional, only used for daemon
-my @base_mod = qw(Email::MIME Devel::Peek);
+my @base_mod = qw(Devel::Peek);
my @over_mod = qw(DBD::SQLite DBI);
my %mod_groups = (
-index => [ @base_mod, @over_mod ],
diff --git a/lib/PublicInbox/Filter/Vger.pm b/lib/PublicInbox/Filter/Vger.pm
index e746238c..2c73738d 100644
--- a/lib/PublicInbox/Filter/Vger.pm
+++ b/lib/PublicInbox/Filter/Vger.pm
@@ -5,7 +5,7 @@
package PublicInbox::Filter::Vger;
use base qw(PublicInbox::Filter::Base);
use strict;
-use warnings;
+use PublicInbox::Eml;
my $l0 = qr/-+/; # older messages only had one '-'
my $l1 =
@@ -25,7 +25,7 @@ sub scrub {
# 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 = PublicInbox::MIME->new(\$s);
+ $mime = PublicInbox::Eml->new(\$s);
}
$self->ACCEPT($mime);
}
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index de8ff55f..98aa7785 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -15,6 +15,7 @@ use PublicInbox::Address;
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
use PublicInbox::ContentId qw(content_digest);
use PublicInbox::MDA;
+use PublicInbox::Eml;
use POSIX qw(strftime);
sub new {
@@ -137,7 +138,7 @@ sub check_remove_v1 {
$info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info";
my $oid = $1;
my $msg = _cat_blob($r, $w, $oid) or die "BUG: cat-blob $1 failed";
- my $cur = PublicInbox::MIME->new($msg);
+ my $cur = PublicInbox::Eml->new($msg);
my $cur_s = $cur->header('Subject');
$cur_s = '' unless defined $cur_s;
my $cur_m = $mime->header('Subject');
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 186eb420..617b692b 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -7,7 +7,7 @@ use strict;
use warnings;
use PublicInbox::Git;
use PublicInbox::MID qw(mid2path);
-use PublicInbox::MIME;
+use PublicInbox::Eml;
# Long-running "git-cat-file --batch" processes won't notice
# unlinked packs, so we need to restart those processes occasionally.
@@ -328,7 +328,7 @@ sub msg_by_smsg ($$;$) {
sub smsg_mime {
my ($self, $smsg, $ref) = @_;
if (my $s = msg_by_smsg($self, $smsg, $ref)) {
- $smsg->{mime} = PublicInbox::MIME->new($s);
+ $smsg->{mime} = PublicInbox::Eml->new($s);
return $smsg;
}
}
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index 31aa76c6..3558403b 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -117,7 +117,7 @@ sub mime_from_path ($) {
local $/;
my $str = <$fh>;
$str or return;
- return PublicInbox::MIME->new(\$str);
+ return PublicInbox::Eml->new(\$str);
} elsif ($!{ENOENT}) {
# common with Maildir
return;
@@ -162,7 +162,7 @@ sub mb_add ($$$$) {
} elsif ($variant eq 'mboxo') {
$$msg =~ s/^>From /From /gms;
}
- my $mime = PublicInbox::MIME->new($msg);
+ my $mime = PublicInbox::Eml->new($msg);
if ($filter) {
my $ret = $filter->scrub($mime) or return;
return if $ret == REJECT();
diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm
index 33696528..57b436b9 100644
--- a/lib/PublicInbox/MDA.pm
+++ b/lib/PublicInbox/MDA.pm
@@ -5,7 +5,6 @@
package PublicInbox::MDA;
use strict;
use warnings;
-use Email::Simple;
use PublicInbox::MsgTime;
use constant MAX_SIZE => 1024 * 500; # same as spamc default, should be tunable
use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index a7e31b71..f054bb6a 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -10,7 +10,7 @@ package PublicInbox::SearchIdx;
use strict;
use warnings;
use base qw(PublicInbox::Search PublicInbox::Lock);
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::InboxWritable;
use PublicInbox::MID qw/mid_clean mid_mime mids_for_index/;
use PublicInbox::MsgIter;
@@ -365,7 +365,7 @@ sub _msgmap_init ($) {
}
sub add_message {
- # mime = Email::MIME object
+ # mime = PublicInbox::Eml or Email::MIME object
my ($self, $mime, $smsg) = @_;
my $hdr = $mime->header_obj;
my $mids = mids_for_index($hdr);
@@ -554,7 +554,7 @@ sub do_cat_mail {
my ($git, $blob, $sizeref) = @_;
my $str = $git->cat_file($blob, $sizeref) or
die "BUG: $blob not found in $git->{git_dir}";
- PublicInbox::MIME->new($str);
+ PublicInbox::Eml->new($str);
}
# called by public-inbox-index
diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm
index 06bcd403..e754b038 100644
--- a/lib/PublicInbox/SearchIdxShard.pm
+++ b/lib/PublicInbox/SearchIdxShard.pm
@@ -8,6 +8,7 @@ use strict;
use warnings;
use base qw(PublicInbox::SearchIdx);
use IO::Handle (); # autoflush
+use PublicInbox::Eml;
sub new {
my ($class, $v2writable, $shard) = @_;
@@ -75,7 +76,7 @@ sub shard_worker_loop ($$$$$) {
$self->begin_txn_lazy;
my $n = read($r, my $msg, $bytes) or die "read: $!\n";
$n == $bytes or die "short read: $n != $bytes\n";
- my $mime = PublicInbox::MIME->new(\$msg);
+ my $mime = PublicInbox::Eml->new(\$msg);
my $smsg = bless {
bytes => $bytes,
num => $num + 0,
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 600843f0..978c3cd7 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -8,12 +8,15 @@ use parent qw(Exporter);
use Fcntl qw(FD_CLOEXEC F_SETFD F_GETFD :seek);
use POSIX qw(dup2);
use IO::Socket::INET;
+use PublicInbox::MIME; # temporary
our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
run_script start_script key2sub xsys xqx mime_load eml_load);
sub mime_load ($) {
my ($path) = @_;
open(my $fh, '<', $path) or die "open $path: $!";
+ # test should've called: require_mods('Email::MIME')
+ require PublicInbox::MIME;
PublicInbox::MIME->new(\(do { local $/; <$fh> }));
}
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 01b8bed6..f599e0a0 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -9,7 +9,7 @@ use warnings;
use base qw(PublicInbox::Lock);
use 5.010_001;
use PublicInbox::SearchIdxShard;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::Git;
use PublicInbox::Import;
use PublicInbox::MID qw(mids references);
@@ -357,9 +357,10 @@ sub content_ids ($) {
my ($mime) = @_;
my @cids = ( content_id($mime) );
+ # We still support Email::MIME, here, and
# Email::MIME->as_string doesn't always round-trip, so we may
# use a second content_id
- my $rt = content_id(PublicInbox::MIME->new(\($mime->as_string)));
+ my $rt = content_id(PublicInbox::Eml->new(\($mime->as_string)));
push @cids, $rt if $cids[0] ne $rt;
\@cids;
}
@@ -405,7 +406,7 @@ sub rewrite_internal ($$;$$$) {
next; # continue
}
my $orig = $$msg;
- my $cur = PublicInbox::MIME->new($msg);
+ my $cur = PublicInbox::Eml->new($msg);
if (content_matches($cids, $cur)) {
$gone{$smsg->{num}} = [ $smsg, $cur, \$orig ];
}
@@ -842,7 +843,7 @@ sub content_exists ($$$) {
warn "broken smsg for $mid\n";
next;
}
- my $cur = PublicInbox::MIME->new($msg);
+ my $cur = PublicInbox::Eml->new($msg);
return 1 if content_matches($cids, $cur);
# XXX DEBUG_DIFF is experimental and may be removed
@@ -870,7 +871,7 @@ sub mark_deleted ($$$$) {
my ($self, $sync, $git, $oid) = @_;
return if PublicInbox::SearchIdx::too_big($self, $git, $oid);
my $msgref = $git->cat_file($oid);
- my $mime = PublicInbox::MIME->new($$msgref);
+ my $mime = PublicInbox::Eml->new($$msgref);
my $mids = mids($mime->header_obj);
my $cid = content_id($mime);
foreach my $mid (@$mids) {
@@ -901,7 +902,7 @@ sub reindex_oid_m ($$$$;$) {
$self->{current_info} = "multi_mid $oid";
my ($num, $mid0, $len);
my $msgref = $git->cat_file($oid, \$len);
- my $mime = PublicInbox::MIME->new($$msgref);
+ my $mime = PublicInbox::Eml->new($$msgref);
my $mids = mids($mime->header_obj);
my $cid = content_id($mime);
die "BUG: reindex_oid_m called for <=1 mids" if scalar(@$mids) <= 1;
@@ -999,7 +1000,7 @@ sub reindex_oid ($$$$) {
my ($num, $mid0, $len);
my $msgref = $git->cat_file($oid, \$len);
return if $len == 0; # purged
- my $mime = PublicInbox::MIME->new($$msgref);
+ my $mime = PublicInbox::Eml->new($$msgref);
my $mids = mids($mime->header_obj);
my $cid = content_id($mime);
@@ -1193,7 +1194,7 @@ sub unindex_oid ($$$;$) {
my ($self, $git, $oid, $unindexed) = @_;
my $mm = $self->{mm};
my $msgref = $git->cat_file($oid);
- my $mime = PublicInbox::MIME->new($msgref);
+ my $mime = PublicInbox::Eml->new($msgref);
my $mids = mids($mime->header_obj);
$mime = $msgref = undef;
my $over = $self->{over};
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 3328c865..ef5f4b3a 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -56,7 +56,7 @@ sub msg_page {
} else {
$first = $ibx->msg_by_mid($mid) or return;
}
- my $mime = PublicInbox::MIME->new($first);
+ my $mime = PublicInbox::Eml->new($first);
$ctx->{-obfs_ibx} = $ibx->{obfuscate} ? $ibx : undef;
my $hdr = $ctx->{hdr} = $mime->header_obj;
$ctx->{obuf} = _msg_page_prepare_obuf($hdr, $ctx, 0);
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index 6c016b03..71fe1f4b 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -146,7 +146,7 @@ sub preload {
require PublicInbox::Feed;
require PublicInbox::View;
require PublicInbox::SearchThread;
- require PublicInbox::MIME;
+ require PublicInbox::Eml;
require PublicInbox::Mbox;
require PublicInbox::ViewVCS;
require PublicInbox::WwwText;
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 71bd84fc..7ca35403 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -6,7 +6,7 @@
package PublicInbox::WatchMaildir;
use strict;
use warnings;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::InboxWritable;
use File::Temp 0.19 (); # 0.19 for ->newdir
use PublicInbox::Filter::Base qw(REJECT);
@@ -282,7 +282,7 @@ sub _spamcheck_cb {
my ($mime) = @_;
my $tmp = '';
if ($sc->spamcheck($mime, \$tmp)) {
- return PublicInbox::MIME->new(\$tmp);
+ return PublicInbox::Eml->new(\$tmp);
}
warn $mime->header('Message-ID')." failed spam check\n";
undef;
diff --git a/lib/PublicInbox/WwwAttach.pm b/lib/PublicInbox/WwwAttach.pm
index b1009907..5b2914b3 100644
--- a/lib/PublicInbox/WwwAttach.pm
+++ b/lib/PublicInbox/WwwAttach.pm
@@ -7,8 +7,7 @@ use strict;
use warnings;
use bytes (); # only for bytes::length
use Email::MIME::ContentType qw(parse_content_type);
-use PublicInbox::MIME;
-use PublicInbox::MsgIter;
+use PublicInbox::Eml;
sub get_attach_i { # ->each_part callback
my ($part, $depth, $idx) = @{$_[0]};
@@ -38,7 +37,7 @@ sub get_attach ($$$) {
my ($ctx, $idx, $fn) = @_;
my $res = [ 404, [ 'Content-Type', 'text/plain' ], [ "Not found\n" ] ];
my $mime = $ctx->{-inbox}->msg_by_mid($ctx->{mid}) or return $res;
- $mime = PublicInbox::MIME->new($mime);
+ $mime = PublicInbox::Eml->new($mime);
$res->[3] = $idx;
$mime->each_part(\&get_attach_i, $res, 1);
pop @$res; # cleanup before letting PSGI server see it
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) || [];
diff --git a/t/filter_rubylang.t b/t/filter_rubylang.t
index 05e1b324..e6c53f98 100644
--- a/t/filter_rubylang.t
+++ b/t/filter_rubylang.t
@@ -3,7 +3,7 @@
use strict;
use warnings;
use Test::More;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::TestCommon;
use_ok 'PublicInbox::Filter::RubyLang';
@@ -17,7 +17,7 @@ keep this
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>
EOF
-my $mime = PublicInbox::MIME->new($msg);
+my $mime = PublicInbox::Eml->new($msg);
my $ret = $f->delivery($mime);
is($ret, $mime, "delivery successful");
is($mime->body, "keep this\n", 'normal message filtered OK');
@@ -41,7 +41,7 @@ X-Mail-Count: 12
Message-ID: <a@b>
EOF
- $mime = PublicInbox::MIME->new($msg);
+ $mime = PublicInbox::Eml->new($msg);
$ret = $f->delivery($mime);
is($ret, $mime, "delivery successful");
my $mm = PublicInbox::Msgmap->new($git_dir);
@@ -53,7 +53,7 @@ Message-ID: <b@b>
EOF
- $mime = PublicInbox::MIME->new($msg);
+ $mime = PublicInbox::Eml->new($msg);
$ret = $f->delivery($mime);
is($ret, 100, "delivery rejected without X-Mail-Count");
}
diff --git a/t/import.t b/t/import.t
index d2264102..ba4abd9c 100644
--- a/t/import.t
+++ b/t/import.t
@@ -75,7 +75,7 @@ $im->done;
is(scalar @revs, 26, '26 revisions exist after mass import');
my ($mark, $msg) = $im->remove($mime);
like($mark, qr/\A:\d+\z/, 'got mark');
-is(ref($msg), 'PublicInbox::MIME', 'got old message deleted');
+like(ref($msg), qr/\bPublicInbox::(?:Eml|MIME)\b/, 'got old message deleted');
is(undef, $im->remove($mime), 'remove is idempotent');
^ permalink raw reply related [relevance 4%]
* [PATCH 00/13] eml: pure-Perl replacement for Email::MIME
@ 2020-05-07 21:05 7% Eric Wong
2020-05-07 21:05 4% ` [PATCH 07/13] replace most uses of PublicInbox::MIME with Eml Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-05-07 21:05 UTC (permalink / raw)
To: meta
Eric Wong (13):
msg_iter: make ->each_part method for PublicInbox::MIME
msg_iter: pass $idx as a scalar, not array
filter/rubylang: avoid recursing subparts to strip trailers
smsg: use capitalization for header retrieval
eml: pure-Perl replacement for Email::MIME
switch read-only Email::Simple users to Eml
replace most uses of PublicInbox::MIME with Eml
EmlContentFoo: Email::MIME::ContentType replacement
EmlContentFoo: relax Encode version requirement
eml: remove dependency on Email::MIME::Encodings
xt: eml comparison tests
remove most internal Email::MIME usage
eml: drop trailing blank line on missing epilogue
Documentation/mknews.perl | 4 +-
INSTALL | 26 +-
MANIFEST | 7 +
Makefile.PL | 7 +-
ci/deps.perl | 3 -
lib/PublicInbox/Admin.pm | 2 +-
lib/PublicInbox/Eml.pm | 421 +++++++++++++++++++++++++++++
lib/PublicInbox/EmlContentFoo.pm | 317 ++++++++++++++++++++++
lib/PublicInbox/Filter/RubyLang.pm | 32 ++-
lib/PublicInbox/Filter/Vger.pm | 4 +-
lib/PublicInbox/Import.pm | 11 +-
lib/PublicInbox/Inbox.pm | 4 +-
lib/PublicInbox/InboxWritable.pm | 4 +-
lib/PublicInbox/MDA.pm | 1 -
lib/PublicInbox/MIME.pm | 6 +
lib/PublicInbox/Mbox.pm | 16 +-
lib/PublicInbox/MboxGz.pm | 4 +-
lib/PublicInbox/MsgIter.pm | 21 +-
lib/PublicInbox/MsgTime.pm | 8 +-
lib/PublicInbox/NNTP.pm | 19 +-
lib/PublicInbox/SearchIdx.pm | 8 +-
lib/PublicInbox/SearchIdxShard.pm | 3 +-
lib/PublicInbox/Smsg.pm | 24 +-
lib/PublicInbox/SolverGit.pm | 4 +-
lib/PublicInbox/TestCommon.pm | 11 +-
lib/PublicInbox/V2Writable.pm | 17 +-
lib/PublicInbox/View.pm | 28 +-
lib/PublicInbox/WWW.pm | 8 +-
lib/PublicInbox/WatchMaildir.pm | 4 +-
lib/PublicInbox/WwwAttach.pm | 15 +-
script/public-inbox-edit | 8 +-
script/public-inbox-learn | 4 +-
script/public-inbox-mda | 16 +-
script/public-inbox-purge | 4 +-
t/altid.t | 4 +-
t/altid_v2.t | 4 +-
t/cgi.t | 8 +-
t/content_id.t | 6 +-
t/convert-compact.t | 4 +-
t/edit.t | 20 +-
t/eml.t | 363 +++++++++++++++++++++++++
t/eml_content_disposition.t | 102 +++++++
t/eml_content_type.t | 289 ++++++++++++++++++++
t/feed.t | 6 +-
t/filter_base.t | 4 +-
t/filter_mirror.t | 2 +-
t/filter_rubylang.t | 8 +-
t/filter_subjecttag.t | 4 +-
t/filter_vger.t | 6 +-
t/html_index.t | 4 +-
t/httpd.t | 4 +-
t/import.t | 6 +-
t/indexlevels-mirror.t | 4 +-
t/mda.t | 4 +-
t/mda_filter_rubylang.t | 2 +-
t/mid.t | 4 +-
t/mime.t | 82 +++---
t/msg_iter.t | 10 +-
t/msgtime.t | 6 +-
t/multi-mid.t | 6 +-
t/nntp.t | 4 +-
t/nntpd-tls.t | 4 +-
t/nntpd.t | 6 +-
t/nulsubject.t | 2 +-
t/plack.t | 10 +-
t/precheck.t | 10 +-
t/psgi_attach.t | 2 +-
t/psgi_bad_mids.t | 4 +-
t/psgi_mount.t | 4 +-
t/psgi_multipart_not.t | 4 +-
t/psgi_scan_all.t | 4 +-
t/psgi_search.t | 8 +-
t/psgi_text.t | 2 +-
t/psgi_v2.t | 6 +-
t/purge.t | 2 +-
t/replace.t | 12 +-
t/reply.t | 4 +-
t/search-thr-index.t | 6 +-
t/search.t | 26 +-
t/solver_git.t | 4 +-
t/spamcheck_spamc.t | 8 +-
t/thread-cycle.t | 3 +-
t/time.t | 4 +-
t/v1-add-remove-add.t | 4 +-
t/v1reindex.t | 4 +-
t/v2-add-remove-add.t | 4 +-
t/v2mda.t | 4 +-
t/v2mirror.t | 4 +-
t/v2reindex.t | 8 +-
t/v2writable.t | 8 +-
t/watch_filter_rubylang.t | 2 +-
t/watch_maildir.t | 2 +-
t/watch_maildir_v2.t | 2 +-
t/www_altid.t | 2 +-
t/xcpdb-reshard.t | 4 +-
xt/cmp-msgstr.t | 108 ++++++++
xt/cmp-msgview.t | 95 +++++++
xt/msgtime_cmp.t | 12 +-
xt/perf-msgview.t | 2 +-
99 files changed, 2084 insertions(+), 353 deletions(-)
create mode 100644 lib/PublicInbox/Eml.pm
create mode 100644 lib/PublicInbox/EmlContentFoo.pm
create mode 100644 t/eml.t
create mode 100644 t/eml_content_disposition.t
create mode 100644 t/eml_content_type.t
create mode 100644 xt/cmp-msgstr.t
create mode 100644 xt/cmp-msgview.t
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-05-07 21:05 7% [PATCH 00/13] eml: pure-Perl replacement for Email::MIME Eric Wong
2020-05-07 21:05 4% ` [PATCH 07/13] replace most uses of PublicInbox::MIME with Eml 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).