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 <[email protected]>
---
 lib/PublicInbox/Import.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index f320c58c6b57..4e3b4c551797 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -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);
                }
-- 
2.17.1

--
unsubscribe: [email protected]
archive: https://public-inbox.org/meta/

Reply via email to