-# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# ref: https://cr.yp.to/proto/maildir.html
use strict;
use warnings;
use PublicInbox::MIME;
-use Email::MIME::ContentType;
-$Email::MIME::ContentType::STRICT_PARAMS = 0; # user input is imperfect
use PublicInbox::Git;
use PublicInbox::Import;
use PublicInbox::MDA;
my ($self) = @_;
my $importers = $self->{importers};
foreach my $im (values %$importers) {
- $im->done if $im->{nchg};
+ $im->barrier;
}
my $opendirs = $self->{opendirs};
# path must be marked as (S)een
$path =~ /:2,[A-R]*S[T-Za-z]*\z/ or return;
my $mime = _path_to_mime($path) or return;
- _force_mid($mime);
$self->{config}->each_inbox(sub {
my ($ibx) = @_;
eval {
})
}
-# used to hash the relevant portions of a message when there are conflicts
-sub _hash_mime2 {
- my ($mime) = @_;
- require Digest::SHA;
- my $dig = Digest::SHA->new('SHA-1');
- $dig->add($mime->header_obj->header_raw('Subject'));
- $dig->add($mime->body_raw);
- $dig->hexdigest;
-}
-
-sub _force_mid {
- my ($mime) = @_;
- # probably a bad idea, but we inject a Message-Id if
- # one is missing, here..
- my $mid = $mime->header_obj->header_raw('Message-Id');
- if (!defined $mid || $mid =~ /\A\s*\z/) {
- $mid = '<' . _hash_mime2($mime) . '@generated>';
- $mime->header_set('Message-Id', $mid);
- }
-}
-
sub _try_path {
my ($self, $path) = @_;
my @p = split(m!/+!, $path);
- return if $p[-1] !~ /\A[a-zA-Z0-9][\w:,=\.]+\z/;
+ return if $p[-1] !~ /\A[a-zA-Z0-9][\-\w:,=\.]+\z/;
if ($p[-1] =~ /:2,([A-Z]+)\z/i) {
my $flags = $1;
return if $flags =~ /[DT]/; # no [D]rafts or [T]rashed mail
$mime = $ret;
}
- _force_mid($mime);
$im->add($mime, $self->{spamcheck});
}