user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 07/13] replace most uses of PublicInbox::MIME with Eml
Date: Thu,  7 May 2020 21:05:50 +0000	[thread overview]
Message-ID: <20200507210556.22995-8-e@yhbt.net> (raw)
In-Reply-To: <20200507210556.22995-1-e@yhbt.net>

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');
 

  parent reply	other threads:[~2020-05-07 21:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 21:05 [PATCH 00/13] eml: pure-Perl replacement for Email::MIME Eric Wong
2020-05-07 21:05 ` [PATCH 01/13] msg_iter: make ->each_part method for PublicInbox::MIME Eric Wong
2020-05-07 21:05 ` [PATCH 02/13] msg_iter: pass $idx as a scalar, not array Eric Wong
2020-05-07 21:05 ` [PATCH 03/13] filter/rubylang: avoid recursing subparts to strip trailers Eric Wong
2020-05-07 21:05 ` [PATCH 04/13] smsg: use capitalization for header retrieval Eric Wong
2020-05-07 21:05 ` [PATCH 05/13] eml: pure-Perl replacement for Email::MIME Eric Wong
2020-05-07 21:05 ` [PATCH 06/13] switch read-only Email::Simple users to Eml Eric Wong
2020-05-07 21:05 ` Eric Wong [this message]
2020-05-07 21:05 ` [PATCH 08/13] EmlContentFoo: Email::MIME::ContentType replacement Eric Wong
2020-05-07 21:05 ` [PATCH 09/13] EmlContentFoo: relax Encode version requirement Eric Wong
2020-05-07 21:05 ` [PATCH 10/13] eml: remove dependency on Email::MIME::Encodings Eric Wong
2020-05-07 21:05 ` [PATCH 11/13] xt: eml comparison tests Eric Wong
2020-05-08  4:47   ` Eric Wong
2020-05-07 21:05 ` [PATCH 12/13] remove most internal Email::MIME usage Eric Wong
2020-05-07 21:05 ` [PATCH 13/13] eml: drop trailing blank line on missing epilogue 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=20200507210556.22995-8-e@yhbt.net \
    --to=e@yhbt.net \
    --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.
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).