Skip to content

Commit

Permalink
git-send-email: handle email address with quoted comma
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wu Fengguang authored and Junio C Hamano committed Dec 20, 2008
1 parent 04c8ce9 commit 0e73b3e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use warnings;
use Term::ReadLine;
use Getopt::Long;
use Text::ParseWords;
use Data::Dumper;
use Term::ANSIColor;
use Git;
Expand Down Expand Up @@ -363,6 +364,10 @@ sub read_config {
die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
}

sub split_addrs {
return parse_line('\s*,\s*', 1, @_);
}

my %aliases;
my %parse_alias = (
# multiline formats can be supported in the future
Expand All @@ -371,7 +376,7 @@ sub read_config {
my ($alias, $addr) = ($1, $2);
$addr =~ s/#.*$//; # mutt allows # comments
# commas delimit multiple addresses
$aliases{$alias} = [ split(/\s*,\s*/, $addr) ];
$aliases{$alias} = [ split_addrs($addr) ];
}}},
mailrc => sub { my $fh = shift; while (<$fh>) {
if (/^alias\s+(\S+)\s+(.*)$/) {
Expand All @@ -380,7 +385,7 @@ sub read_config {
}}},
pine => sub { my $fh = shift; while (<$fh>) {
if (/^(\S+)\t.*\t(.*)$/) {
$aliases{$1} = [ split(/\s*,\s*/, $2) ];
$aliases{$1} = [ split_addrs($2) ];
}}},
gnus => sub { my $fh = shift; while (<$fh>) {
if (/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/) {
Expand Down Expand Up @@ -458,7 +463,7 @@ sub read_config {
}

my $to = $_;
push @to, split /,\s*/, $to;
push @to, split_addrs($to);
$prompting++;
}

Expand Down

0 comments on commit 0e73b3e

Please sign in to comment.