Offering links to download 0-byte files is useless. We could
waste memory by preserving $eml->{bdy} during iteration, but
offering attachments of type "multipart" is not very useful,
as users are usually interested in decoded attachments or
the entire raw message.
Fixes: e60231148eb604a3 ("descend into message/(rfc822|news|global) parts")
sub attach_link ($$$$;$) {
my ($ctx, $ct, $p, $fn, $err) = @_;
my ($part, $depth, $idx) = @$p;
sub attach_link ($$$$;$) {
my ($ctx, $ct, $p, $fn, $err) = @_;
my ($part, $depth, $idx) = @$p;
+
+ # Eml iteration clobbers multipart ->{bdy}, so do not offer
+ # downloads for 0-byte multipart attachments
+ return unless $part->{bdy};
+
my $nl = $idx eq '1' ? '' : "\n"; # like join("\n", ...)
my $size = bytes::length($part->body);
my $nl = $idx eq '1' ? '' : "\n"; # like join("\n", ...)
my $size = bytes::length($part->body);
my $mid = '20200418222508.GA13918@dcvr';
my $irt = '20200418222020.GA2745@dcvr';
$res = $cb->(GET("/test/$mid/"));
my $mid = '20200418222508.GA13918@dcvr';
my $irt = '20200418222020.GA2745@dcvr';
$res = $cb->(GET("/test/$mid/"));
+ unlike($res->content, qr! multipart/mixed, Size: 0 bytes!,
+ '0-byte download not offered');
like($res->content, qr/\bhref="2-embed2x\.eml"/s,
'href to message/rfc822 attachment visible');
like($res->content, qr/\bhref="2\.1\.2-test\.eml"/s,
like($res->content, qr/\bhref="2-embed2x\.eml"/s,
'href to message/rfc822 attachment visible');
like($res->content, qr/\bhref="2\.1\.2-test\.eml"/s,