]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: use defined-or operator to simplify checks
authorEric Wong <e@yhbt.net>
Sat, 4 Apr 2020 08:03:16 +0000 (08:03 +0000)
committerEric Wong <e@yhbt.net>
Sat, 4 Apr 2020 23:34:27 +0000 (23:34 +0000)
We depend on Perl 5.10 features in other places.  Shorten the
lifetime of the `$desc' scalar while we're at it.

lib/PublicInbox/View.pm

index d897aeecc3ed3abf6ba2dc71bb9540cbf3ec0bdd..9ef1f68ae914fdbf54ce5f9aa029449917b7a171 100644 (file)
@@ -504,9 +504,6 @@ sub attach_link ($$$$;$) {
        # spotting MUA problems:
        $ct =~ s/;.*// unless $err;
        $ct = ascii_html($ct);
        # spotting MUA problems:
        $ct =~ s/;.*// unless $err;
        $ct = ascii_html($ct);
-       my $desc = $part->header('Content-Description');
-       $desc = $fn unless defined $desc;
-       $desc = '' unless defined $desc;
        my $sfn;
        if (defined $fn && $fn =~ /\A$PublicInbox::Hval::FN\z/o) {
                $sfn = $fn;
        my $sfn;
        if (defined $fn && $fn =~ /\A$PublicInbox::Hval::FN\z/o) {
                $sfn = $fn;
@@ -524,6 +521,7 @@ EOF
        }
        $$rv .= "[-- Attachment #$idx: ";
        my $ts = "Type: $ct, Size: $size bytes";
        }
        $$rv .= "[-- Attachment #$idx: ";
        my $ts = "Type: $ct, Size: $size bytes";
+       my $desc = $part->header('Content-Description') // $fn // '';
        $desc = ascii_html($desc);
        $$rv .= ($desc eq '') ? "$ts --]" : "$desc --]\n[-- $ts --]";
        $$rv .= "</a>\n";
        $desc = ascii_html($desc);
        $$rv .= ($desc eq '') ? "$ts --]" : "$desc --]\n[-- $ts --]";
        $$rv .= "</a>\n";