]> Sergey Matveev's repositories - public-inbox.git/commitdiff
import: drop '<' and '>' characters in addresses
authorEric Wong <e@yhbt.net>
Wed, 26 Feb 2020 10:21:12 +0000 (10:21 +0000)
committerEric Wong <e@yhbt.net>
Sun, 1 Mar 2020 23:18:53 +0000 (17:18 -0600)
Some strange "From:" lines will cause Email::Address::XS to
leave '<' (and presumably '>') in the address which
git-fast-import won't accept even if quoted.  Workaround this
problem by deleting '<' and '>' the same way we delete them for
the ident name.

Reported-by: Leah Neukirchen <leah@vuxu.org>
Link: https://public-inbox.org/meta/87h7zfemur.fsf@vuxu.org/
lib/PublicInbox/Import.pm
t/import.t

index d8dc49b82f9494815b2d49e140560fbe2fbc41b7..68dc0c7e83c1b223796ee171200d879065e1add2 100644 (file)
@@ -293,6 +293,10 @@ sub extract_cmt_info ($) {
                }
        }
        if (defined $email) {
+               # Email::Address::XS may leave quoted '<' in addresses,
+               # which git-fast-import doesn't like
+               $email =~ tr/<>//d;
+
                # quiet down wide character warnings with utf8::encode
                utf8::encode($email);
        } else {
index e71dd7146354a5a3d85e52d97b4ac68319878671..b88d308e919079d5216f6bafe9cc018c4397e9c8 100644 (file)
@@ -55,6 +55,8 @@ $im->done;
 my @revs = $git->qx(qw(rev-list HEAD));
 is(scalar @revs, 1, 'one revision created');
 
+my $odd = '"=?iso-8859-1?Q?J_K=FCpper?= <usenet"@example.de';
+$mime->header_set('From', $odd);
 $mime->header_set('Message-ID', '<b@example.com>');
 $mime->header_set('Subject', 'msg2');
 like($im->add($mime, sub { $mime }), qr/\A:\d+\z/, 'added 2nd message');