Move the creation of the scripts used in to-cmd and cc-cmd tests
in a setup test to make them available for later tests.
Signed-off-by: Remi Lespinet <redacted>
---
t/t9001-send-email.sh | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
@@ -1579,6 +1579,66 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' 'grep"^!o@example\.com!$"commandline1'+test_expect_success$PREREQ'alias support in To header''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1--to=sbd>aliased.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--smtp-server="$(pwd)/fake.sendmail"\+aliased.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'alias support in Cc header''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1--cc=sbd>aliased.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--smtp-server="$(pwd)/fake.sendmail"\+aliased.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'tocmd works with aliases''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1>tocmd.patch&&+echotocmd--sbd>>tocmd.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--to-cmd=./tocmd-sed\+--smtp-server="$(pwd)/fake.sendmail"\+tocmd.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'cccmd works with aliases''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1>cccmd.patch&&+echocccmd--sbd>>cccmd.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--cc-cmd=./cccmd-sed\+--smtp-server="$(pwd)/fake.sendmail"\+cccmd.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'+ do_xmailer_test(){expected=$1params=$2&&gitformat-patch-1&&
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 <redacted>
---
git-send-email.perl | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
@@ -833,12 +833,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(
@@ -1051,6 +1048,13 @@ sub sanitize_address_list {return(map{sanitize_address($_)}@_);}+subprocess_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
@@ -1560,10 +1564,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);
Group expressions in a single if statement. This avoid checking
multiple time if the variable $sender is defined.
Signed-off-by: Remi Lespinet <redacted>
---
git-send-email.perl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Aliases were expanded before checking the From field of the
--compose option. This is inconsistent with other fields
(To, Cc, ...) which already support aliases.
Signed-off-by: Remi Lespinet <redacted>
---
git-send-email.perl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -555,8 +555,6 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {}}-($sender)=expand_aliases($sender)ifdefined$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.subis_format_patch_arg{
@@ -801,6 +799,8 @@ if (!$force) {}}+($sender)=expand_aliases($sender)ifdefined$sender;+if(!defined$sender){$sender=$repoauthor||$repocommitter||'';}
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 [off-list ref]
In this case the result of parse_address_line is:
With M::A : "Jane Do" e [off-list ref]
Without : "Jane Do e" [off-list ref]
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 <redacted>
---
git-send-email.perl | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
Do not consider quote inside a recipient name as character when
they are not escaped. This interprets:
"Jane" "Doe" [off-list ref]
as:
"Jane Doe" [off-list ref]
instead of:
"Jane\" \"Doe" [off-list ref]
Signed-off-by: Remi Lespinet <redacted>
---
I don't know if it's an argument for this change, but rfc2822 says:
Semantically, neither the optional CFWS outside of the quote
characters nor the quote characters themselves are part of the
quoted-string...
git-send-email.perl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -1078,15 +1078,17 @@ sub sanitize_address {return$recipient;}+# remove non-escaped quotes+$recipient_name=~s/(^|[^\\])"/$1/g;+# rfc2047 is needed if a non-ascii char is includedif($recipient_name=~ /[^[:ascii:]]/){-$recipient_name=~s/^"(.*)"$/$1/;$recipient_name=quote_rfc2047($recipient_name);}# double quotes are needed if specials or CTLs are includedelsif($recipient_name=~ /[][()<>@,;:\\".\000-\037\177]/){-$recipient_name=~s/(["\\\r])/\\$1/g;+$recipient_name=~s/([\\\r])/\\$1/g;$recipient_name=qq["$recipient_name"];}
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 [off-list ref], 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.
Helped-by: Remi Lespinet [off-list ref]
Signed-off-by: Mathieu Lienard--Mayor <redacted>
Signed-off-by: Jorge Juan Garcia Garcia <redacted>
Signed-off-by: Matthieu Moy <redacted>
Signed-off-by: Remi Lespinet <redacted>
---
Documentation/git-send-email.txt | 12 +++++------
git-send-email.perl | 17 ++--------------
t/t9001-send-email.sh | 44 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 21 deletions(-)
@@ -49,17 +49,17 @@ Composing of 'sendemail.annotate'. See the CONFIGURATION section for 'sendemail.multiEdit'.---bcc=<address>::+--bcc=<address>,...:: Specify a "Bcc:" value for each email. Default is the value of 'sendemail.bcc'. +-The --bcc option must be repeated for each user you want on the bcc list.+This option may be specified multiple times.---cc=<address>::+--cc=<address>,...:: Specify a starting "Cc:" value for each email. Default is the value of 'sendemail.cc'. +-The --cc option must be repeated for each user you want on the cc list.+This option may be specified multiple times. --compose:: Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
@@ -110,13 +110,13 @@ is not set, this will be prompted for. Only necessary if --compose is also set. If --compose is not set, this will be prompted for.---to=<address>::+--to=<address>,...:: Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the 'sendemail.to' configuration value; if that is unspecified, and --to-cmd is not specified, this will be prompted for. +-The --to option must be repeated for each user you want on the to list.+This option may be specified multiple times. --8bit-encoding=<encoding>:: When encountering a non-ASCII message or subject that does not
@@ -460,20 +460,6 @@ my ($repoauthor, $repocommitter);($repoauthor)=Git::ident_person(@repo,'author');($repocommitter)=Git::ident_person(@repo,'committer');-# Verify the user input--foreachmy$entry(@initial_to){-die"Comma in --to entry: $entry'\n"unless$entry!~m/,/;-}--foreachmy$entry(@initial_cc){-die"Comma in --cc entry: $entry'\n"unless$entry!~m/,/;-}--foreachmy$entry(@bcclist){-die"Comma in --bcclist entry: $entry'\n"unless$entry!~m/,/;-}-subparse_address_line{if($have_mail_address){returnmap{$_->format}Mail::Address->parse($_[0]);
@@ -1101,7 +1087,8 @@ sub sanitize_address_list {}subprocess_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;
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 <redacted>
---
git-send-email.perl | 1 +
t/t9001-send-email.sh | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
Move the creation of the scripts used in to-cmd and cc-cmd tests
in a setup test to make them available for later tests.
Signed-off-by: Remi Lespinet <redacted>
---
t/t9001-send-email.sh | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
Group expressions in a single if statement. This avoid checking
multiple time if the variable $sender is defined.
Signed-off-by: Remi Lespinet <redacted>
---
git-send-email.perl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -1579,6 +1579,66 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' 'grep"^!o@example\.com!$"commandline1'+test_expect_success$PREREQ'alias support in To header''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1--to=sbd>aliased.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--smtp-server="$(pwd)/fake.sendmail"\+aliased.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'alias support in Cc header''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1--cc=sbd>aliased.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--smtp-server="$(pwd)/fake.sendmail"\+aliased.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'tocmd works with aliases''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1>tocmd.patch&&+echotocmd--sbd>>tocmd.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--to-cmd=./tocmd-sed\+--smtp-server="$(pwd)/fake.sendmail"\+tocmd.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'cccmd works with aliases''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1>cccmd.patch&&+echocccmd--sbd>>cccmd.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--cc-cmd=./cccmd-sed\+--smtp-server="$(pwd)/fake.sendmail"\+cccmd.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'+ do_xmailer_test(){expected=$1params=$2&&gitformat-patch-1&&
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 <redacted>
---
git-send-email.perl | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
@@ -833,12 +833,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(
@@ -1051,6 +1048,13 @@ sub sanitize_address_list {return(map{sanitize_address($_)}@_);}+subprocess_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
@@ -1560,10 +1564,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);
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 <redacted>
---
git-send-email.perl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -555,8 +555,6 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {}}-($sender)=expand_aliases($sender)ifdefined$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.subis_format_patch_arg{
@@ -801,6 +799,8 @@ if (!$force) {}}+($sender)=expand_aliases($sender)ifdefined$sender;+if(!defined$sender){$sender=$repoauthor||$repocommitter||'';}
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 [off-list ref]
In this case the result of parse_address_line is:
With M::A : "Jane Do" e [off-list ref]
Without : "Jane Do e" [off-list ref]
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 <redacted>
---
I've added the function in Git.pm as suggested. I've also added a test
named t9000-addresses.sh (I've read the README to name tests but I'm
not sure about the name of this test). I made a separated test
(t9000-addresses.sh) because I think it's better not to pollute
t9001-send-email with this.
About the test itself, file t/t9000-addresses.sh is just a copy/paste
of t/t0202-gettext-perl.sh. For the perl part, the TODO tests are
verbose: they print out commands whereas test_expect_success doesn't.
We can redirect todo_output to a variable but I've not found better...
(Maybe someone has the solution here ?). Also there's no summary at
the end of the test (as with other perl tests).
git-send-email.perl | 2 +-
perl/Git.pm | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
t/t9000-addresses.sh | 25 ++++++++++++++++++
t/t9000/test.pl | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 164 insertions(+), 1 deletion(-)
create mode 100755 t/t9000-addresses.sh
create mode 100755 t/t9000/test.pl
@@ -1584,6 +1584,73 @@ sub DESTROY {$self->_close_cat_blob();}+=itemparse_mailboxes++Returnsanarrayofmailboxesextractedfromastring.++=cut++subparse_mailboxes{+my$re_comment=qr/\((?:[^)]*)\)/;+my$re_quote=qr/"(?:[^\"\\]|\\.)*"/;+my$re_word=qr/(?:[^]["\s()<>:;@\\,.]|\\.)+/;++# divide the string in tokens of the above form+my$re_token=qr/(?:$re_quote|$re_word|$re_comment|\S)/;+my@tokens=map{$_=~/\s*($re_token)\s*/g}@_;++# add a delimiter to simplify treatment for the last mailbox+push@tokens,",";++my(@addr_list,@phrase,@address,@comment,@buffer)=();+foreachmy$token(@tokens){+if($token=~/^[,;]$/){+# if buffer still contains undeterminated strings+# append it at the end of @address or @phrase+if(@address){+push@address,@buffer;+}else{+push@phrase,@buffer;+}++my$str_phrase=join' ',@phrase;+my$str_address=join'',@address;+my$str_comment=join' ',@comment;++# quote are necessary if phrase contains+# special characters+if($str_phrase=~/[][()<>:;@\\,.\000-\037\177]/){+$str_phrase=~s/(^|[^\\])"/$1/g;+$str_phrase=qq["$str_phrase"];+}++# add "<>" around the address if necessary+if($str_addressne""&&$str_phrasene""){+$str_address=qq[<$str_address>];+}++my$str_mailbox="$str_phrase $str_address $str_comment";+$str_mailbox=~s/^\s*|\s*$//g;+push@addr_list,$str_mailboxif($str_mailbox);++@phrase=@address=@comment=@buffer=();+}elsif($token=~/^\(/){+push@comment,$token;+}elsif($tokeneq"<"){+push@phrase,(splice@address),(splice@buffer);+}elsif($tokeneq">"){+push@address,(splice@buffer);+}elsif($tokeneq"@"){+push@address,(splice@buffer),"@";+}elsif($tokeneq"."){+push@address,(splice@buffer),".";+}else{+push@buffer,$token;+}+}++return@addr_list;+}# Pipe implementation for ActiveState Perl.
This is the last message I received in the series, and it's labeled 07/10. Is that normal?
parse_address_line had not the same behavior whether the user had
had not -> did not have
I've added the function in Git.pm as suggested. I've also added a test
named t9000-addresses.sh (I've read the README to name tests but I'm
not sure about the name of this test). I made a separated test
(t9000-addresses.sh) because I think it's better not to pollute
t9001-send-email with this.
Sounds good to me.
About the test itself, file t/t9000-addresses.sh is just a copy/paste
of t/t0202-gettext-perl.sh. For the perl part, the TODO tests are
verbose: they print out commands whereas test_expect_success doesn't.
It seems it's how Test::More works. I'd keep it like this, but I have no real experience with Test::More.
We can redirect todo_output to a variable but I've not found better...
(Maybe someone has the solution here ?). Also there's no summary at
the end of the test (as with other perl tests).
You can get the 1..44 at the end with
printf "1..%d\n", Test::More->builder->current_test;
This is what t9700/test.pl does.
This will fail if Mail::Address is not available. It would be better to declare Mail::Address as a prerequisite in t9000-address.sh (like what you're already doing for Test::More).
Good job, modulo these minor details, the series looks good to me.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Do not consider quote inside a recipient name as character when
they are not escaped. This interprets:
"Jane" "Doe" [off-list ref]
as:
"Jane Doe" [off-list ref]
instead of:
"Jane\" \"Doe" [off-list ref]
Signed-off-by: Remi Lespinet <redacted>
---
git-send-email.perl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -1028,15 +1028,17 @@ sub sanitize_address {return$recipient;}+# remove non-escaped quotes+$recipient_name=~s/(^|[^\\])"/$1/g;+# rfc2047 is needed if a non-ascii char is includedif($recipient_name=~ /[^[:ascii:]]/){-$recipient_name=~s/^"(.*)"$/$1/;$recipient_name=quote_rfc2047($recipient_name);}# double quotes are needed if specials or CTLs are includedelsif($recipient_name=~ /[][()<>@,;:\\".\000-\037\177]/){-$recipient_name=~s/(["\\\r])/\\$1/g;+$recipient_name=~s/([\\\r])/\\$1/g;$recipient_name=qq["$recipient_name"];}
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 <redacted>
---
git-send-email.perl | 1 +
t/t9001-send-email.sh | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
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 [off-list ref], 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.
Helped-by: Remi Lespinet [off-list ref]
Signed-off-by: Mathieu Lienard--Mayor <redacted>
Signed-off-by: Jorge Juan Garcia Garcia <redacted>
Signed-off-by: Matthieu Moy <redacted>
Signed-off-by: Remi Lespinet <redacted>
---
Documentation/git-send-email.txt | 12 +++++------
git-send-email.perl | 17 ++--------------
t/t9001-send-email.sh | 44 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 21 deletions(-)
@@ -49,17 +49,17 @@ Composing of 'sendemail.annotate'. See the CONFIGURATION section for 'sendemail.multiEdit'.---bcc=<address>::+--bcc=<address>,...:: Specify a "Bcc:" value for each email. Default is the value of 'sendemail.bcc'. +-The --bcc option must be repeated for each user you want on the bcc list.+This option may be specified multiple times.---cc=<address>::+--cc=<address>,...:: Specify a starting "Cc:" value for each email. Default is the value of 'sendemail.cc'. +-The --cc option must be repeated for each user you want on the cc list.+This option may be specified multiple times. --compose:: Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
@@ -110,13 +110,13 @@ is not set, this will be prompted for. Only necessary if --compose is also set. If --compose is not set, this will be prompted for.---to=<address>::+--to=<address>,...:: Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the 'sendemail.to' configuration value; if that is unspecified, and --to-cmd is not specified, this will be prompted for. +-The --to option must be repeated for each user you want on the to list.+This option may be specified multiple times. --8bit-encoding=<encoding>:: When encountering a non-ASCII message or subject that does not
@@ -460,20 +460,6 @@ my ($repoauthor, $repocommitter);($repoauthor)=Git::ident_person(@repo,'author');($repocommitter)=Git::ident_person(@repo,'committer');-# Verify the user input--foreachmy$entry(@initial_to){-die"Comma in --to entry: $entry'\n"unless$entry!~m/,/;-}--foreachmy$entry(@initial_cc){-die"Comma in --cc entry: $entry'\n"unless$entry!~m/,/;-}--foreachmy$entry(@bcclist){-die"Comma in --bcclist entry: $entry'\n"unless$entry!~m/,/;-}-subparse_address_line{if($have_mail_address){returnmap{$_->format}Mail::Address->parse($_[0]);
@@ -1051,7 +1037,8 @@ sub sanitize_address_list {}subprocess_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;
This is the last message I received in the series, and it's labeled
07/10. Is that normal?
No, it wasn't, I have seen no error message though... I'll take a look
at that later. I just sent 0008, 0009 and 0010 but I seems that I've pasted
the wrong line in the in-reply-to... Maybe I need more sleep.
quoted
We can redirect todo_output to a variable but I've not found better...
(Maybe someone has the solution here ?). Also there's no summary at
the end of the test (as with other perl tests).
You can get the 1..44 at the end with
...
I would have put parse_mailbox near ident_person because both
functions are somehow about email.
This will fail if Mail::Address is not available. It would be better
to declare Mail::Address as a prerequisite in t9000-address.sh (like
what you're already doing for Test::More).
We can redirect todo_output to a variable but I've not found better...
(Maybe someone has the solution here ?). Also there's no summary at
the end of the test (as with other perl tests).
You can get the 1..44 at the end with
printf "1..%d\n", Test::More->builder->current_test;
This is what t9700/test.pl does.
I can also get it by removing the line
Test::More->builder->no_ending(1);
and replacing
use Test::More;
by
use Test::More "no_plan";
I think I'm going to do that, because the no_ending thing makes the
test suite success even if every test fails: at the end we have
# test_external test Perl address parsing function was ok
# test_external_without_stderr test no stderr: Perl address parsing function was ok
in case everything is ok. With the "no_ending" line, only the second
line reports failures, the first is always the same.
I think both must be marked red.
Move the creation of the scripts used in to-cmd and cc-cmd tests
in a setup test to make them available for later tests.
Signed-off-by: Remi Lespinet <redacted>
---
t/t9001-send-email.sh | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
@@ -1579,6 +1579,66 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' 'grep"^!o@example\.com!$"commandline1'+test_expect_success$PREREQ'alias support in To header''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1--to=sbd>aliased.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--smtp-server="$(pwd)/fake.sendmail"\+aliased.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'alias support in Cc header''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1--cc=sbd>aliased.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--smtp-server="$(pwd)/fake.sendmail"\+aliased.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'tocmd works with aliases''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1>tocmd.patch&&+echotocmd--sbd>>tocmd.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--to-cmd=./tocmd-sed\+--smtp-server="$(pwd)/fake.sendmail"\+tocmd.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'++test_expect_success$PREREQ'cccmd works with aliases''+clean_fake_sendmail&&+echo"alias sbd someone@example.org">.mailrc&&+test_configsendemail.aliasesfile".mailrc"&&+test_configsendemail.aliasfiletypemailrc&&+gitformat-patch--stdout-1>cccmd.patch&&+echocccmd--sbd>>cccmd.patch&&+gitsend-email\+--from="Example <nobody@example.com>"\+--cc-cmd=./cccmd-sed\+--smtp-server="$(pwd)/fake.sendmail"\+cccmd.patch\+2>errors>out&&+grep"^!someone@example\.org!$"commandline1+'+ do_xmailer_test(){expected=$1params=$2&&gitformat-patch-1&&
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 <redacted>
---
git-send-email.perl | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
@@ -833,12 +833,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(
@@ -1051,6 +1048,13 @@ sub sanitize_address_list {return(map{sanitize_address($_)}@_);}+subprocess_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
@@ -1560,10 +1564,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);
Group expressions in a single if statement. This avoid checking
multiple time if the variable $sender is defined.
Signed-off-by: Remi Lespinet <redacted>
---
git-send-email.perl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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 <redacted>
---
git-send-email.perl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
@@ -555,8 +555,6 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {}}-($sender)=expand_aliases($sender)ifdefined$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.subis_format_patch_arg{
@@ -801,6 +799,8 @@ if (!$force) {}}+($sender)=expand_aliases($sender)ifdefined$sender;+if(!defined$sender){$sender=$repoauthor||$repocommitter||'';}
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 [off-list ref]
In this case the result of parse_address_line is:
With M::A : "Jane Do" e [off-list ref]
Without : "Jane Do e" [off-list ref]
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 <redacted>
---
git-send-email.perl | 2 +-
perl/Git.pm | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
t/t9000-addresses.sh | 30 +++++++++++++++++++++++
t/t9000/test.pl | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 165 insertions(+), 1 deletion(-)
create mode 100755 t/t9000-addresses.sh
create mode 100755 t/t9000/test.pl
@@ -864,6 +864,73 @@ sub ident_person {return"$ident[0] <$ident[1]>";}+=itemparse_mailboxes++Returnanarrayofmailboxesextractedfromastring.++=cut++subparse_mailboxes{+my$re_comment=qr/\((?:[^)]*)\)/;+my$re_quote=qr/"(?:[^\"\\]|\\.)*"/;+my$re_word=qr/(?:[^]["\s()<>:;@\\,.]|\\.)+/;++# divide the string in tokens of the above form+my$re_token=qr/(?:$re_quote|$re_word|$re_comment|\S)/;+my@tokens=map{$_=~/\s*($re_token)\s*/g}@_;++# add a delimiter to simplify treatment for the last mailbox+push@tokens,",";++my(@addr_list,@phrase,@address,@comment,@buffer)=();+foreachmy$token(@tokens){+if($token=~/^[,;]$/){+# if buffer still contains undeterminated strings+# append it at the end of @address or @phrase+if(@address){+push@address,@buffer;+}else{+push@phrase,@buffer;+}++my$str_phrase=join' ',@phrase;+my$str_address=join'',@address;+my$str_comment=join' ',@comment;++# quote are necessary if phrase contains+# special characters+if($str_phrase=~/[][()<>:;@\\,.\000-\037\177]/){+$str_phrase=~s/(^|[^\\])"/$1/g;+$str_phrase=qq["$str_phrase"];+}++# add "<>" around the address if necessary+if($str_addressne""&&$str_phrasene""){+$str_address=qq[<$str_address>];+}++my$str_mailbox="$str_phrase $str_address $str_comment";+$str_mailbox=~s/^\s*|\s*$//g;+push@addr_list,$str_mailboxif($str_mailbox);++@phrase=@address=@comment=@buffer=();+}elsif($token=~/^\(/){+push@comment,$token;+}elsif($tokeneq"<"){+push@phrase,(splice@address),(splice@buffer);+}elsif($tokeneq">"){+push@address,(splice@buffer);+}elsif($tokeneq"@"){+push@address,(splice@buffer),"@";+}elsif($tokeneq"."){+push@address,(splice@buffer),".";+}else{+push@buffer,$token;+}+}++return@addr_list;+}=itemhash_object(TYPE,FILENAME)
Do not consider quote inside a recipient name as character when
they are not escaped. This interprets:
"Jane" "Doe" [off-list ref]
as:
"Jane Doe" [off-list ref]
instead of:
"Jane\" \"Doe" [off-list ref]
Signed-off-by: Remi Lespinet <redacted>
---
git-send-email.perl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -1028,15 +1028,17 @@ sub sanitize_address {return$recipient;}+# remove non-escaped quotes+$recipient_name=~s/(^|[^\\])"/$1/g;+# rfc2047 is needed if a non-ascii char is includedif($recipient_name=~ /[^[:ascii:]]/){-$recipient_name=~s/^"(.*)"$/$1/;$recipient_name=quote_rfc2047($recipient_name);}# double quotes are needed if specials or CTLs are includedelsif($recipient_name=~ /[][()<>@,;:\\".\000-\037\177]/){-$recipient_name=~s/(["\\\r])/\\$1/g;+$recipient_name=~s/([\\\r])/\\$1/g;$recipient_name=qq["$recipient_name"];}
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 [off-list ref], 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.
Helped-by: Remi Lespinet [off-list ref]
Signed-off-by: Mathieu Lienard--Mayor <redacted>
Signed-off-by: Jorge Juan Garcia Garcia <redacted>
Signed-off-by: Matthieu Moy <redacted>
Signed-off-by: Remi Lespinet <redacted>
---
Documentation/git-send-email.txt | 12 +++++------
git-send-email.perl | 17 ++--------------
t/t9001-send-email.sh | 44 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 21 deletions(-)
@@ -49,17 +49,17 @@ Composing of 'sendemail.annotate'. See the CONFIGURATION section for 'sendemail.multiEdit'.---bcc=<address>::+--bcc=<address>,...:: Specify a "Bcc:" value for each email. Default is the value of 'sendemail.bcc'. +-The --bcc option must be repeated for each user you want on the bcc list.+This option may be specified multiple times.---cc=<address>::+--cc=<address>,...:: Specify a starting "Cc:" value for each email. Default is the value of 'sendemail.cc'. +-The --cc option must be repeated for each user you want on the cc list.+This option may be specified multiple times. --compose:: Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
@@ -110,13 +110,13 @@ is not set, this will be prompted for. Only necessary if --compose is also set. If --compose is not set, this will be prompted for.---to=<address>::+--to=<address>,...:: Specify the primary recipient of the emails generated. Generally, this will be the upstream maintainer of the project involved. Default is the value of the 'sendemail.to' configuration value; if that is unspecified, and --to-cmd is not specified, this will be prompted for. +-The --to option must be repeated for each user you want on the to list.+This option may be specified multiple times. --8bit-encoding=<encoding>:: When encountering a non-ASCII message or subject that does not
@@ -460,20 +460,6 @@ my ($repoauthor, $repocommitter);($repoauthor)=Git::ident_person(@repo,'author');($repocommitter)=Git::ident_person(@repo,'committer');-# Verify the user input--foreachmy$entry(@initial_to){-die"Comma in --to entry: $entry'\n"unless$entry!~m/,/;-}--foreachmy$entry(@initial_cc){-die"Comma in --cc entry: $entry'\n"unless$entry!~m/,/;-}--foreachmy$entry(@bcclist){-die"Comma in --bcclist entry: $entry'\n"unless$entry!~m/,/;-}-subparse_address_line{if($have_mail_address){returnmap{$_->format}Mail::Address->parse($_[0]);
@@ -1051,7 +1037,8 @@ sub sanitize_address_list {}subprocess_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;
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 <redacted>
---
git-send-email.perl | 1 +
t/t9001-send-email.sh | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)