lib/PublicInbox/Import.pm | 8 ++++---- lib/PublicInbox/V2Writable.pm | 2 +- t/psgi_v2.t | 9 +++++---- t/v2writable.t | 8 ++++---- diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 6824faca21dc3205ecd12be9899cb1e14f0e3834..e07eddab4f245a2a47f368d5dd223d26e2a56770 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -297,12 +297,12 @@ $mime->header_set($_) for @PublicInbox::MDA::BAD_HEADERS; } # used by V2Writable, too -sub prepend_mid ($$) { +sub append_mid ($$) { my ($hdr, $mid0) = @_; # @cur is likely empty if we need to call this sub, but it could # have random unparseable crap which we'll preserve, too. - my @cur = $hdr->header_raw('Message-Id'); - $hdr->header_set('Message-Id', "<$mid0>", @cur); + my @cur = $hdr->header_raw('Message-ID'); + $hdr->header_set('Message-ID', @cur, "<$mid0>"); } sub v1_mid0 ($) { @@ -312,7 +312,7 @@ my $mids = mids($hdr); if (!scalar(@$mids)) { # spam often has no Message-Id my $mid0 = digest2mid(content_digest($mime)); - prepend_mid($hdr, $mid0); + append_mid($hdr, $mid0); return $mid0; } $mids->[0]; diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 01ec98ac58c332655b0f31d38a1c551f784b21ae..9b280c686b547e303dde7245a34d6d9ed93b6a6d 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -173,7 +173,7 @@ warn "using random Message-ID <$$mid0> as fallback\n"; $num = $self->{skel}->{mm}->mid_insert($$mid0); } } - PublicInbox::Import::prepend_mid($hdr, $$mid0); + PublicInbox::Import::append_mid($hdr, $$mid0); $num; } diff --git a/t/psgi_v2.t b/t/psgi_v2.t index 9964b47762abce93e83d3749340e5c798d1c89f5..11b2c794e238634c66dac443d60b64d1e717a817 100644 --- a/t/psgi_v2.t +++ b/t/psgi_v2.t @@ -7,6 +7,7 @@ use File::Temp qw/tempdir/; use PublicInbox::MIME; use PublicInbox::Config; use PublicInbox::WWW; +use PublicInbox::MID qw(mids); my @mods = qw(DBD::SQLite Search::Xapian HTTP::Request::Common Plack::Test URI::Escape Plack::Builder); foreach my $mod (@mods) { @@ -46,8 +47,8 @@ local $SIG{__WARN__} = sub { push @warn, @_ }; $mime->header_set(Date => 'Fri, 02 Oct 1993 00:01:00 +0000'); ok($im->add($mime), 'added duplicate-but-different message'); is(scalar(@warn), 1, 'got one warning'); -my @mids = $mime->header_obj->header_raw('Message-Id'); -$new_mid = PublicInbox::MID::mid_clean($mids[0]); +my $mids = mids($mime->header_obj); +$new_mid = $mids->[1]; $im->done; my $cfgpfx = "publicinbox.v2test"; @@ -93,8 +94,8 @@ is(scalar(@warn), 2, 'got another warning'); like($warn[0], qr/mismatched/, 'warned about mismatched messages'); is($warn[0], $warn[1], 'both warnings are the same'); -@mids = $mime->header_obj->header_raw('Message-Id'); -my $third = PublicInbox::MID::mid_clean($mids[0]); +$mids = mids($mime->header_obj); +my $third = $mids->[-1]; $im->done; test_psgi(sub { $www->call(@_) }, sub { diff --git a/t/v2writable.t b/t/v2writable.t index 6cabf0d575b1eac0a22d0549e0792dad7b578054..c48f060e87978e979fcc72ff64540e42412e104a 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -79,8 +79,8 @@ $mime->body_set('different'); ok($im->add($mime), 'reused mid ok'); like(join(' ', @warn), qr/reused/, 'warned about reused MID'); my @mids = $mime->header_obj->header_raw('Message-Id'); - is($mids[1], '', 'original mid not changed'); - like($mids[0], $sane_mid, 'new MID added'); + is($mids[0], '', 'original mid not changed'); + like($mids[1], $sane_mid, 'new MID added'); is(scalar(@mids), 2, 'only one new MID added'); @warn = (); @@ -95,8 +95,8 @@ is_deeply(\@warn, [], 'no warnings from a faker'); ok($im->add($mime), 'random MID made'); like(join(' ', @warn), qr/using random/, 'warned about using random'); @mids = $mime->header_obj->header_raw('Message-Id'); - is($mids[1], '', 'original mid not changed'); - like($mids[0], $sane_mid, 'new MID added'); + is($mids[0], '', 'original mid not changed'); + like($mids[1], $sane_mid, 'new MID added'); is(scalar(@mids), 2, 'only one new MID added'); @warn = ();