From 8604ccc806997eadf78e2b6352b4daa0287b8bb0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 25 May 2020 08:21:37 +0000 Subject: view: do not offer links to 0-byte multipart attachments 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") --- lib/PublicInbox/View.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/PublicInbox/View.pm') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 93a5b329..a05ac414 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -499,6 +499,11 @@ sub submsg_hdr ($$) { 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); -- cgit v1.2.3-24-ge0c7