# 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);
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
}
# 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 ],
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 =
# 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);
}
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 {
$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');
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.
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;
}
}
local $/;
my $str = <$fh>;
$str or return;
- return PublicInbox::MIME->new(\$str);
+ return PublicInbox::Eml->new(\$str);
} elsif ($!{ENOENT}) {
# common with Maildir
return;
} 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();
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
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;
}
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);
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
use warnings;
use base qw(PublicInbox::SearchIdx);
use IO::Handle (); # autoflush
+use PublicInbox::Eml;
sub new {
my ($class, $v2writable, $shard) = @_;
$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,
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> }));
}
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);
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;
}
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 ];
}
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
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) {
$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;
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);
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};
} 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);
require PublicInbox::Feed;
require PublicInbox::View;
require PublicInbox::SearchThread;
- require PublicInbox::MIME;
+ require PublicInbox::Eml;
require PublicInbox::Mbox;
require PublicInbox::ViewVCS;
require PublicInbox::WwwText;
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);
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;
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]};
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
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;
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
$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:
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";
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;
exit $code;
};
-use Email::Simple;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::MDA;
use PublicInbox::Config;
use PublicInbox::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';
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";
}
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;
}
$do_exit->(67) if $err && scalar(@$dests) == 0;
-$simple = undef;
+$eml = undef;
my $spam_ok;
if ($spamc) {
$str = '';
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
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";
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) || [];
use strict;
use warnings;
use Test::More;
-use PublicInbox::MIME;
+use PublicInbox::Eml;
use PublicInbox::TestCommon;
use_ok 'PublicInbox::Filter::RubyLang';
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');
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);
EOF
- $mime = PublicInbox::MIME->new($msg);
+ $mime = PublicInbox::Eml->new($msg);
$ret = $f->delivery($mime);
is($ret, 100, "delivery rejected without X-Mail-Count");
}
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');