diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-10-05 12:08:05 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@linbit.com> | 2011-10-05 12:11:47 +0200 |
commit | c6750845136ff21eb13bc99ec7a6e1689100a13a (patch) | |
tree | 6cdfed836983057850d094a052a1d905ade3464b | |
parent | d2b4b7a2fd61df4ab33cbbaf8efdcfc44f1028bb (diff) | |
download | quilt-c6750845136ff21eb13bc99ec7a6e1689100a13a.tar.gz |
quilt mail: Support double quoted special characters in email adresses
Addresses like "Gruenbacher, Andreas" <agruen@linbit.com> will work now.
-rw-r--r-- | quilt/scripts/edmail.in | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/quilt/scripts/edmail.in b/quilt/scripts/edmail.in index 8c87218..10aa771 100644 --- a/quilt/scripts/edmail.in +++ b/quilt/scripts/edmail.in @@ -121,6 +121,23 @@ sub check_recipient($) { } } +sub split_recipients($) { + my ($recipients) = @_; + my @list = (); + + while ($recipients !~ /^\s*$/) { + my $recipient; + if ($recipients =~ s/^\s*,?\s*((?:"(?:[^"]+)"|[^",])*)//) { + $recipient = $1; s/\s*$//; + } else { + $recipient = $recipients; + $recipients = ""; + } + push @list, $recipient; + } + return @list; +} + my %recipients; sub process_header($) { local ($_) = @_; @@ -133,11 +150,8 @@ sub process_header($) { } if (%extract_recipients_from) { if (exists $extract_recipients_from{lc $name}) { - #print "(($value))"; $value =~ s/^\s*//; $value =~ s/\s*$//; - foreach my $recipient (split /\s*,\s*/s, $value) { - next if $recipient =~ /^\s*$/; - #print "<<$recipient>>"; + foreach my $recipient (split_recipients($value)) { my $deliver; ($recipient, $deliver) = check_recipient($recipient); print "$deliver\n"; @@ -161,9 +175,7 @@ sub process_header($) { my @recipients; # This is a recipients field. Split out all the recipients and # check the addresses. Suppress duplicate recipients. - $value =~ s/^\s*//; $value =~ s/\s*$//; - foreach my $recipient (split /\s*,\s*/, $value) { - next if $recipient =~ /^\s*$/; + foreach my $recipient (split_recipients($value)) { my $deliver; ($recipient, $deliver) = check_recipient($recipient); unless (exists $recipients{$deliver}) { |