Skip to content

Commit 0e73b3e

Browse files
Wu Fengguanggitster
authored andcommitted
git-send-email: handle email address with quoted comma
Correctly handle email addresses containing quoted commas, e.g. "Zhu, Yi" <[email protected]>, "Li, Shaohua" <[email protected]> The commas inside the double quotes are not separators. Signed-off-by: Wu Fengguang <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04c8ce9 commit 0e73b3e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

git-send-email.perl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use warnings;
2121
use Term::ReadLine;
2222
use Getopt::Long;
23+
use Text::ParseWords;
2324
use Data::Dumper;
2425
use Term::ANSIColor;
2526
use Git;
@@ -363,6 +364,10 @@ sub read_config {
363364
die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
364365
}
365366

367+
sub split_addrs {
368+
return parse_line('\s*,\s*', 1, @_);
369+
}
370+
366371
my %aliases;
367372
my %parse_alias = (
368373
# multiline formats can be supported in the future
@@ -371,7 +376,7 @@ sub read_config {
371376
my ($alias, $addr) = ($1, $2);
372377
$addr =~ s/#.*$//; # mutt allows # comments
373378
# commas delimit multiple addresses
374-
$aliases{$alias} = [ split(/\s*,\s*/, $addr) ];
379+
$aliases{$alias} = [ split_addrs($addr) ];
375380
}}},
376381
mailrc => sub { my $fh = shift; while (<$fh>) {
377382
if (/^alias\s+(\S+)\s+(.*)$/) {
@@ -380,7 +385,7 @@ sub read_config {
380385
}}},
381386
pine => sub { my $fh = shift; while (<$fh>) {
382387
if (/^(\S+)\t.*\t(.*)$/) {
383-
$aliases{$1} = [ split(/\s*,\s*/, $2) ];
388+
$aliases{$1} = [ split_addrs($2) ];
384389
}}},
385390
gnus => sub { my $fh = shift; while (<$fh>) {
386391
if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
@@ -458,7 +463,7 @@ sub read_config {
458463
}
459464

460465
my $to = $_;
461-
push @to, split /,\s*/, $to;
466+
push @to, split_addrs($to);
462467
$prompting++;
463468
}
464469

0 commit comments

Comments
 (0)