git-send-email: handle email address with quoted comma
Correctly handle email addresses containing quoted commas, e.g. "Zhu, Yi" <yi.zhu@intel.com>, "Li, Shaohua" <shaohua.li@intel.com> The commas inside the double quotes are not separators. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Wu Fengguang committed
Dec 19, 2008 at 16:10 UTC
0e73b3ee6ca95e1db2fe801d2b8544f4c27991df
1 file changed
+8
-3
git-send-email.perl
+8
-3
@@ -20,6 +20,7 @@ use strict;
20
use warnings;
21
use Term::ReadLine;
22
use Getopt::Long;
23
+use Text::ParseWords;
24
use Data::Dumper;
25
use Term::ANSIColor;
26
use Git;
@@ -363,6 +364,10 @@ foreach my $entry (@bcclist) {
364
die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
365
}
366
367
+sub split_addrs {
368
+ return parse_line('\s*,\s*', 1, @_);
369
+}
370
+
371
my %aliases;
372
my %parse_alias = (
373
# multiline formats can be supported in the future
@@ -371,7 +376,7 @@ my %parse_alias = (
376
my ($alias, $addr) = ($1, $2);
377
$addr =~ s/#.*$//; # mutt allows # comments
378
# commas delimit multiple addresses
374
- $aliases{$alias} = [ split(/\s*,\s*/, $addr) ];
379
+ $aliases{$alias} = [ split_addrs($addr) ];
380
}}},
381
mailrc => sub { my $fh = shift; while (<$fh>) {
382
if (/^alias\s+(\S+)\s+(.*)$/) {
@@ -380,7 +385,7 @@ my %parse_alias = (
385
}}},
386
pine => sub { my $fh = shift; while (<$fh>) {
387
if (/^(\S+)\t.*\t(.*)$/) {
383
- $aliases{$1} = [ split(/\s*,\s*/, $2) ];
388
+ $aliases{$1} = [ split_addrs($2) ];
389
}}},
390
gnus => sub { my $fh = shift; while (<$fh>) {
391
if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
@@ -458,7 +463,7 @@ if (!@to) {
463
}
464
465
my $to = $_;
461
- push @to, split /,\s*/, $to;
466
+ push @to, split_addrs($to);
467
$prompting++;
468
}
469