diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-02-15 09:27:55 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-02-15 09:30:52 +0000 |
commit | c54ad85d10c1149361bf2a8120ce8ae38bf7847f (patch) | |
tree | 6001f28d4f156eb01d1a4f7288ecd4feebb44238 /lib/PublicInbox/Import.pm | |
parent | eeabb27977bca531a1918ab85a7714c91ceaee42 (diff) | |
download | public-inbox-c54ad85d10c1149361bf2a8120ce8ae38bf7847f.tar.gz |
There's a lot of crap in archives and git-fast-import accepts empty names and email addresses for authors just fine.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r-- | lib/PublicInbox/Import.pm | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 845fbb69..f8d10037 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -246,11 +246,6 @@ sub add { my $from = $mime->header('From'); my ($email) = PublicInbox::Address::emails($from); my ($name) = PublicInbox::Address::names($from); - # git gets confused with: - # "'A U Thor <u@example.com>' via foo" <foo@example.com> - # ref: - # <CAD0k6qSUYANxbjjbE4jTW4EeVwOYgBD=bXkSu=akiYC_CB7Ffw@mail.gmail.com> - $name =~ tr/<>//d; my $date_raw = parse_date($mime); my $subject = $mime->header('Subject'); @@ -297,10 +292,26 @@ sub add { print $w "reset $ref\n" or wfail; } - utf8::encode($email); - utf8::encode($name); + # quiet down wide character warnings with utf8::encode + if (defined $email) { + utf8::encode($email); + } else { + $email = ''; + warn "no email in From: $from\n"; + } + + # git gets confused with: + # "'A U Thor <u@example.com>' via foo" <foo@example.com> + # ref: + # <CAD0k6qSUYANxbjjbE4jTW4EeVwOYgBD=bXkSu=akiYC_CB7Ffw@mail.gmail.com> + if (defined $name) { + $name =~ tr/<>//d; + utf8::encode($name); + } else { + $name = ''; + warn "no name in From: $from\n"; + } utf8::encode($subject); - # quiet down wide character warnings: print $w "commit $ref\nmark :$commit\n", "author $name <$email> $date_raw\n", "committer $self->{ident} ", now_raw(), "\n" or wfail; |