]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwatomstream: avoid uninitialized warnings for $email
authorEric Wong <e@yhbt.net>
Tue, 7 Jul 2020 20:37:38 +0000 (20:37 +0000)
committerEric Wong <e@yhbt.net>
Fri, 10 Jul 2020 11:27:09 +0000 (11:27 +0000)
As in Import, we'll fall back to Sender: if From: is missing,
and use the primary_address of the inboxes to indicate the total
absence of those fields.

lib/PublicInbox/WwwAtomStream.pm

index 3b5b133a5ec0b707b0b123a6d3e842138c8fa865..2f9b953b2829cea360ea6627c044a56c89a63739 100644 (file)
@@ -136,16 +136,13 @@ sub feed_entry {
        $title = '(no subject)' unless defined $title && $title ne '';
        $title = title_tag($title);
 
-       my $from = $hdr->header('From') or return;
+       my $from = $hdr->header('From') // $hdr->header('Sender') //
+               $ctx->{-inbox}->{-primary_address};
        my ($email) = PublicInbox::Address::emails($from);
-       my $name = join(', ',PublicInbox::Address::names($from));
-       $name = ascii_html($name);
-       $email = ascii_html($email);
+       my $name = ascii_html(join(', ', PublicInbox::Address::names($from)));
+       $email = ascii_html($email // $ctx->{-inbox}->{-primary_address});
 
-       my $s = '';
-       if (delete $ctx->{emit_header}) {
-               $s .= atom_header($ctx, $title);
-       }
+       my $s = delete($ctx->{emit_header}) ? atom_header($ctx, $title) : '';
        $s .= "<entry><author><name>$name</name><email>$email</email>" .
                "</author>$title$updated" .
                qq(<link\nhref="$href"/>).