]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Import.pm
Import.pm: Deal with potentially missing From and Sender headers
[public-inbox.git] / lib / PublicInbox / Import.pm
index b25427ee552628237bc094225f2daf24e98dcdac..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);
                }
@@ -405,6 +407,8 @@ sub add {
                print $w "reset $ref\n" or wfail;
        }
 
+       # Mime decoding can create nulls replace them with spaces to protect git
+       $subject =~ tr/\0/ /;
        utf8::encode($subject);
        print $w "commit $ref\nmark :$commit\n",
                "author $name <$email> $author_time_raw\n",
@@ -440,6 +444,8 @@ sub done {
        _update_git_info($self, 1) if delete $self->{nchg};
 
        $self->lock_release;
+
+       $self->{git}->cleanup;
 }
 
 sub atfork_child {