From f6f79e5ee3d0b0fa1d2084bae31f8ea8e7d5c3f8 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:43 +0200 Subject: send-email: allow aliases in patch header and command script outputs Interpret aliases in: - Header fields of patches generated by git format-patch (using --to, --cc, --add-header for example) or manually modified. Example of fields in header: To: alias1 Cc: alias2 Cc: alias3 - Outputs of command scripts specified by --cc-cmd and --to-cmd. Example of script: #!/bin/sh echo alias1 echo alias2 Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index e1e9b1460c..0cac4b0077 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1535,7 +1535,9 @@ foreach my $t (@files) { ($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1)); $needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc); + @to = expand_aliases(@to); @to = validate_address_list(sanitize_address_list(@to)); + @cc = expand_aliases(@cc); @cc = validate_address_list(sanitize_address_list(@cc)); @to = (@initial_to, @to); -- cgit v1.2.1 From b5e112d8d240b299553f17c8e476ef16fca4001f Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:45 +0200 Subject: send-email: refactor address list process Simplify code by creating a function which transform a list of strings containing email addresses (separated by commas, comporting aliases) into a clean list of valid email addresses. Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 0cac4b0077..05af83993b 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -808,12 +808,9 @@ sub expand_one_alias { return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias; } -@initial_to = expand_aliases(@initial_to); -@initial_to = validate_address_list(sanitize_address_list(@initial_to)); -@initial_cc = expand_aliases(@initial_cc); -@initial_cc = validate_address_list(sanitize_address_list(@initial_cc)); -@bcclist = expand_aliases(@bcclist); -@bcclist = validate_address_list(sanitize_address_list(@bcclist)); +@initial_to = process_address_list(@initial_to); +@initial_cc = process_address_list(@initial_cc); +@bcclist = process_address_list(@bcclist); if ($thread && !defined $initial_reply_to && $prompting) { $initial_reply_to = ask( @@ -1026,6 +1023,13 @@ sub sanitize_address_list { return (map { sanitize_address($_) } @_); } +sub process_address_list { + my @addr_list = expand_aliases(@_); + @addr_list = sanitize_address_list(@addr_list); + @addr_list = validate_address_list(@addr_list); + return @addr_list; +} + # Returns the local Fully Qualified Domain Name (FQDN) if available. # # Tightly configured MTAa require that a caller sends a real DNS @@ -1535,10 +1539,8 @@ foreach my $t (@files) { ($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1)); $needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc); - @to = expand_aliases(@to); - @to = validate_address_list(sanitize_address_list(@to)); - @cc = expand_aliases(@cc); - @cc = validate_address_list(sanitize_address_list(@cc)); + @to = process_address_list(@to); + @cc = process_address_list(@cc); @to = (@initial_to, @to); @cc = (@initial_cc, @cc); -- cgit v1.2.1 From 193d7160111ebf5b898f53240c33c1e4101d9598 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:46 +0200 Subject: send-email: allow use of aliases in the From field of --compose mode Aliases were expanded before considering the From field of the --compose option. This is inconsistent with other fields (To, Cc, ...) which already support aliases. Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 05af83993b..228400b3e9 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -530,8 +530,6 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) { } } -($sender) = expand_aliases($sender) if defined $sender; - # is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if # $f is a revision list specification to be passed to format-patch. sub is_format_patch_arg { @@ -776,6 +774,8 @@ if (!$force) { } } +($sender) = expand_aliases($sender) if defined $sender; + if (!defined $sender) { $sender = $repoauthor || $repocommitter || ''; } -- cgit v1.2.1 From c46e27aa774eae2ac58f1763afe00108f3a1e5d3 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:47 +0200 Subject: send-email: minor code refactoring Group expressions in a single if statement. This avoid checking multiple time if the variable $sender is defined. Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 228400b3e9..09ecad830f 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -774,9 +774,9 @@ if (!$force) { } } -($sender) = expand_aliases($sender) if defined $sender; - -if (!defined $sender) { +if (defined $sender) { + ($sender) = expand_aliases($sender); +} else { $sender = $repoauthor || $repocommitter || ''; } -- cgit v1.2.1 From 8d314d7afec5adaaa8e22332e39fe84a39584653 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 7 Jul 2015 15:38:15 +0200 Subject: send-email: reduce dependencies impact on parse_address_line parse_address_line had not the same behavior whether the user had Mail::Address or not. Teach parse_address_line to behave like Mail::Address. When the user input is correct, this implementation behaves exactly like Mail::Address except when there are quotes inside the name: "Jane Do"e In this case the result of parse_address_line is: With M::A : "Jane Do" e Without : "Jane Do e" When the user input is not correct, the behavior is also mostly the same. Unlike Mail::Address, this doesn't parse groups and recursive commentaries. Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 09ecad830f..486cb36f27 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -478,7 +478,7 @@ sub parse_address_line { if ($have_mail_address) { return map { $_->format } Mail::Address->parse($_[0]); } else { - return split_addrs($_[0]); + return Git::parse_mailboxes($_[0]); } } -- cgit v1.2.1 From 1fe9703f08cfac8bd2db7a17bb6f3a61cf20ef35 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:49 +0200 Subject: send-email: consider quote as delimiter instead of character Do not consider quote inside a recipient name as character when they are not escaped. This interprets: "Jane" "Doe" as: "Jane Doe" instead of: "Jane\" \"Doe" Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 486cb36f27..7eec5f6db5 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -1003,15 +1003,17 @@ sub sanitize_address { return $recipient; } + # remove non-escaped quotes + $recipient_name =~ s/(^|[^\\])"/$1/g; + # rfc2047 is needed if a non-ascii char is included if ($recipient_name =~ /[^[:ascii:]]/) { - $recipient_name =~ s/^"(.*)"$/$1/; $recipient_name = quote_rfc2047($recipient_name); } # double quotes are needed if specials or CTLs are included elsif ($recipient_name =~ /[][()<>@,;:\\".\000-\037\177]/) { - $recipient_name =~ s/(["\\\r])/\\$1/g; + $recipient_name =~ s/([\\\r])/\\$1/g; $recipient_name = qq["$recipient_name"]; } -- cgit v1.2.1 From b1c8a11c8024c88346a06274f87a0605afd4a53b Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:50 +0200 Subject: send-email: allow multiple emails using --cc, --to and --bcc Accept a list of emails separated by commas in flags --cc, --to and --bcc. Multiple addresses can already be given by using these options multiple times, but it is more convenient to allow cutting-and-pasting a list of addresses from the header of an existing e-mail message, which already lists them as comma-separated list, as a value to a single parameter. The following format can now be used: $ git send-email --to='Jane , mike@example.com' Remove the limitation imposed by 79ee555b (Check and document the options to prevent mistakes, 2006-06-21) which rejected every argument with comma in --cc, --to and --bcc. Signed-off-by: Mathieu Lienard--Mayor Signed-off-by: Jorge Juan Garcia Garcia Signed-off-by: Matthieu Moy Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index 7eec5f6db5..f4dbad3051 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -460,20 +460,6 @@ my ($repoauthor, $repocommitter); ($repoauthor) = Git::ident_person(@repo, 'author'); ($repocommitter) = Git::ident_person(@repo, 'committer'); -# Verify the user input - -foreach my $entry (@initial_to) { - die "Comma in --to entry: $entry'\n" unless $entry !~ m/,/; -} - -foreach my $entry (@initial_cc) { - die "Comma in --cc entry: $entry'\n" unless $entry !~ m/,/; -} - -foreach my $entry (@bcclist) { - die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/; -} - sub parse_address_line { if ($have_mail_address) { return map { $_->format } Mail::Address->parse($_[0]); @@ -1026,7 +1012,8 @@ sub sanitize_address_list { } sub process_address_list { - my @addr_list = expand_aliases(@_); + my @addr_list = map { parse_address_line($_) } @_; + @addr_list = expand_aliases(@addr_list); @addr_list = sanitize_address_list(@addr_list); @addr_list = validate_address_list(@addr_list); return @addr_list; -- cgit v1.2.1 From fa5b1aa9a1e1f0ad7b2728bec3712d3fab5fe734 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Tue, 30 Jun 2015 14:16:51 +0200 Subject: send-email: suppress meaningless whitespaces in from field Remove leading and trailing whitespaces in from field before interepreting it to improve consistency with other options. The split_addrs function already take care of trailing and leading whitespaces for to, cc and bcc fields. The from option now: - has the same behavior when passing arguments like " jdoe@example.com ", "\t jdoe@example.com " or "jdoe@example.com". - interprets aliases in string containing leading and trailing whitespaces such as " alias" or "alias\t" like other options. Signed-off-by: Remi Lespinet Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-send-email.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'git-send-email.perl') diff --git a/git-send-email.perl b/git-send-email.perl index f4dbad3051..62fc7d65e8 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -761,6 +761,7 @@ if (!$force) { } if (defined $sender) { + $sender =~ s/^\s+|\s+$//g; ($sender) = expand_aliases($sender); } else { $sender = $repoauthor || $repocommitter || ''; -- cgit v1.2.1