To avoid confusing future readers and users, recommend
PublicInbox::Eml in our Import POD and refer to PublicInbox::Eml
comments at the top of PublicInbox::MIME.
mime_load() confined to t/eml.t, since we won't be using
it anywhere else in our tests.
+ use PublicInbox::Eml;
+ # PublicInbox::Eml exists as of public-inbox 1.5.0,
+ # Email::MIME was used in older versions
+
use PublicInbox::Git;
use PublicInbox::Import;
use PublicInbox::Git;
use PublicInbox::Import;
"Date: Thu, 01 Jan 1970 00:00:00 +0000\n" .
"Message-ID: <m\@example.org>\n".
"\ntest message";
"Date: Thu, 01 Jan 1970 00:00:00 +0000\n" .
"Message-ID: <m\@example.org>\n".
"\ntest message";
- my $parsed = Email::MIME->new($message);
+ my $parsed = PublicInbox::Eml->new($message);
my $ret = $im->add($parsed);
if (!defined $ret) {
warn "duplicate: ",
my $ret = $im->add($parsed);
if (!defined $ret) {
warn "duplicate: ",
$im->done;
# to remove a message
$im->done;
# to remove a message
- my $junk = Email::MIME->new($message);
+ my $junk = PublicInbox::Eml->new($message);
my ($mark, $orig) = $im->remove($junk);
if ($mark eq 'MISSING') {
print "not found\n";
my ($mark, $orig) = $im->remove($junk);
if ($mark eq 'MISSING') {
print "not found\n";
-An importer and remover for public-inboxes which takes L<Email::MIME>
-messages as input and stores them in a git repository as
+An importer and remover for public-inboxes which takes C<PublicInbox::Eml>
+or L<Email::MIME> messages as input and stores them in a git repository as
documented in L<https://public-inbox.org/public-inbox-v1-format.txt>,
except it does not allow duplicate Message-IDs.
documented in L<https://public-inbox.org/public-inbox-v1-format.txt>,
except it does not allow duplicate Message-IDs.
- my $parsed = Email::MIME->new($message);
+ my $parsed = PublicInbox::Eml->new($message);
$im->add($parsed);
Adds a message to to the git repository. This will acquire
$im->add($parsed);
Adds a message to to the git repository. This will acquire
- my $junk = Email::MIME->new($message);
+ my $junk = PublicInbox::Eml->new($message);
my ($code, $orig) = $im->remove($junk);
Removes a message from the repository. On success, it returns
a ':'-prefixed numeric code representing the git-fast-import
my ($code, $orig) = $im->remove($junk);
Removes a message from the repository. On success, it returns
a ':'-prefixed numeric code representing the git-fast-import
-mark and the original messages as an Email::MIME object.
+mark and the original messages as a PublicInbox::Eml
+(or Email::MIME) object.
If the message could not be found, the code is "MISSING"
and the original message is undef. If there is a mismatch where
the "Message-ID" is matched but the subject and body do not match,
If the message could not be found, the code is "MISSING"
and the original message is undef. If there is a mismatch where
the "Message-ID" is matched but the subject and body do not match,
-Copyright (C) 2016 all contributors L<mailto:meta@public-inbox.org>
+Copyright (C) 2016-2020 all contributors L<mailto:meta@public-inbox.org>
License: AGPL-3.0+ L<http://www.gnu.org/licenses/agpl-3.0.txt>
License: AGPL-3.0+ L<http://www.gnu.org/licenses/agpl-3.0.txt>
# The license for this file differs from the rest of public-inbox.
#
# We no longer load this in any of our code outside of maintainer
# The license for this file differs from the rest of public-inbox.
#
# We no longer load this in any of our code outside of maintainer
-# tests for compatibility.
+# tests for compatibility. PublicInbox::Eml is favored throughout
+# our codebase for performance and safety reasons, though we maintain
+# Email::MIME-compatibility in mail injection and indexing code paths.
#
# It monkey patches the "parts_multipart" subroutine with patches
# from Matthew Horsfall <wolfsage@gmail.com> at:
#
# It monkey patches the "parts_multipart" subroutine with patches
# from Matthew Horsfall <wolfsage@gmail.com> at:
use POSIX qw(dup2);
use IO::Socket::INET;
our @EXPORT = qw(tmpdir tcp_server tcp_connect require_git require_mods
use POSIX qw(dup2);
use IO::Socket::INET;
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> }));
-}
+ run_script start_script key2sub xsys xqx eml_load);
sub eml_load ($) {
my ($path, $cb) = @_;
sub eml_load ($) {
my ($path, $cb) = @_;
};
use_ok $_ for @classes;
};
use_ok $_ for @classes;
+sub mime_load ($) {
+ my ($path) = @_;
+ open(my $fh, '<', $path) or die "open $path: $!";
+ PublicInbox::MIME->new(\(do { local $/; <$fh> }));
+}
+
{
my $eml = PublicInbox::Eml->new(\(my $str = "a: b\n\nhi\n"));
is($str, "hi\n", '->new modified body like Email::Simple');
{
my $eml = PublicInbox::Eml->new(\(my $str = "a: b\n\nhi\n"));
is($str, "hi\n", '->new modified body like Email::Simple');