lib/PublicInbox/View.pm | 5 +++++ t/psgi_attach.t | 2 ++ diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 93a5b32915506338bc6bfc28679765bc6e37765a..a05ac4142f29385abeb9b741eb2911cc6cb17fd4 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -499,6 +499,11 @@ 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); diff --git a/t/psgi_attach.t b/t/psgi_attach.t index c6f8072ff9a223c5fbd351957cbe3e6b1bf168d6..9a734f813fae590b960970aed9004da7ca8eebbf 100644 --- a/t/psgi_attach.t +++ b/t/psgi_attach.t @@ -73,6 +73,8 @@ 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,