]> Sergey Matveev's repositories - public-inbox.git/commitdiff
Import.pm: Deal with potentially missing From and Sender headers
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 19 Jul 2018 19:36:31 +0000 (14:36 -0500)
committerEric Wong <e@80x24.org>
Thu, 19 Jul 2018 20:40:49 +0000 (20:40 +0000)
Use ||= '' to ensure that if the From or Sender header is not present
the code sees an empty string and instead of undefined.

I had some email messages with a From field without an @ (because the
sender was local) and without a Sender which were causing errors when
imported.  I think this was bad enough that the email messages were
failing to be imported.

Signed-off-by: Eric Biederamn <ebiederm@xmission.com>
lib/PublicInbox/Import.pm

index f320c58c6b575023ec94dfcd12e8cbd6910f7af4..4e3b4c55179766797b41960ea7c55bc266f210f4 100644 (file)
@@ -278,10 +278,12 @@ sub extract_author_info ($) {
 
        my $sender = '';
        my $from = $mime->header('From');
+       $from ||= '';
        my ($email) = PublicInbox::Address::emails($from);
        my ($name) = PublicInbox::Address::names($from);
        if (!defined($name) || !defined($email)) {
                $sender = $mime->header('Sender');
+               $sender ||= '';
                if (!defined($name)) {
                        ($name) = PublicInbox::Address::names($sender);
                }