# [PATCH] git-send-email: treat field names as case-independent

4 messages from 2013-01-07 to 2013-01-07. Participants: Nickolai Zeldovich, Junio C Hamano.
Thread: https://gitlist.dev/t/32544

## Nickolai Zeldovich, 2013-01-07 01:34

Subject: [PATCH] git-send-email: treat field names as case-independent
Message-ID: <1357522498-8086-1-git-send-email-nickolai@csail.mit.edu>
URL: https://gitlist.dev/e/1357522498-8086-1-git-send-email-nickolai%40csail.mit.edu

```
Field names like To:, Cc:, etc should be treated as case-independent;
use a case-insensitive regexp to match them as such.  Previously,
git-send-email would send email messages with a lowercase "cc:" line in
the body without actually sending a copy of the message to that address.

Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
---
 git-send-email.perl |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index 94c7f76..be809e5 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1285,10 +1285,10 @@ foreach my $t (@files) {
 		}
 
 		if (defined $input_format && $input_format eq 'mbox') {
-			if (/^Subject:\s+(.*)$/) {
+			if (/^Subject:\s+(.*)$/i) {
 				$subject = $1;
 			}
-			elsif (/^From:\s+(.*)$/) {
+			elsif (/^From:\s+(.*)$/i) {
 				($author, $author_encoding) = unquote_rfc2047($1);
 				next if $suppress_cc{'author'};
 				next if $suppress_cc{'self'} and $author eq $sender;
@@ -1296,14 +1296,14 @@ foreach my $t (@files) {
 					$1, $_) unless $quiet;
 				push @cc, $1;
 			}
-			elsif (/^To:\s+(.*)$/) {
+			elsif (/^To:\s+(.*)$/i) {
 				foreach my $addr (parse_address_line($1)) {
 					printf("(mbox) Adding to: %s from line '%s'\n",
 						$addr, $_) unless $quiet;
 					push @to, $addr;
 				}
 			}
-			elsif (/^Cc:\s+(.*)$/) {
+			elsif (/^Cc:\s+(.*)$/i) {
 				foreach my $addr (parse_address_line($1)) {
 					if (unquote_rfc2047($addr) eq $sender) {
 						next if ($suppress_cc{'self'});
@@ -1325,7 +1325,7 @@ foreach my $t (@files) {
 			elsif (/^Message-Id: (.*)/i) {
 				$message_id = $1;
 			}
-			elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) {
+			elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
 				push @xh, $_;
 			}
 
-- 
1.7.10.4

```

## Junio C Hamano, 2013-01-07 03:27

Subject: Re: [PATCH] git-send-email: treat field names as case-independent
Message-ID: <7va9sllljh.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7va9sllljh.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1357522498-8086-1-git-send-email-nickolai@csail.mit.edu>

```
Nickolai Zeldovich <nickolai@csail.mit.edu> writes:

> Field names like To:, Cc:, etc should be treated as case-independent;
> use a case-insensitive regexp to match them as such.  Previously,
> git-send-email would send email messages with a lowercase "cc:" line in
> the body without actually sending a copy of the message to that address.
>
> Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
> ---

While I think this patch is a sensible thing to do, I at the same
time wonder who is writing "cc:" in the lowercase in the first
place, and if that is one of our tools, we should fix that part as
well.  Such a header would leak out to the payload given to the
underlying sendmail, doesn't it?

Leaking such lowercased headers of course is not a crime (the
headers are case insensitive), but they look ugly.

>  git-send-email.perl |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 94c7f76..be809e5 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1285,10 +1285,10 @@ foreach my $t (@files) {
>  		}
>  
>  		if (defined $input_format && $input_format eq 'mbox') {
> -			if (/^Subject:\s+(.*)$/) {
> +			if (/^Subject:\s+(.*)$/i) {
>  				$subject = $1;
>  			}
> -			elsif (/^From:\s+(.*)$/) {
> +			elsif (/^From:\s+(.*)$/i) {
>  				($author, $author_encoding) = unquote_rfc2047($1);
>  				next if $suppress_cc{'author'};
>  				next if $suppress_cc{'self'} and $author eq $sender;
> @@ -1296,14 +1296,14 @@ foreach my $t (@files) {
>  					$1, $_) unless $quiet;
>  				push @cc, $1;
>  			}
> -			elsif (/^To:\s+(.*)$/) {
> +			elsif (/^To:\s+(.*)$/i) {
>  				foreach my $addr (parse_address_line($1)) {
>  					printf("(mbox) Adding to: %s from line '%s'\n",
>  						$addr, $_) unless $quiet;
>  					push @to, $addr;
>  				}
>  			}
> -			elsif (/^Cc:\s+(.*)$/) {
> +			elsif (/^Cc:\s+(.*)$/i) {
>  				foreach my $addr (parse_address_line($1)) {
>  					if (unquote_rfc2047($addr) eq $sender) {
>  						next if ($suppress_cc{'self'});
> @@ -1325,7 +1325,7 @@ foreach my $t (@files) {
>  			elsif (/^Message-Id: (.*)/i) {
>  				$message_id = $1;
>  			}
> -			elsif (!/^Date:\s/ && /^[-A-Za-z]+:\s+\S/) {
> +			elsif (!/^Date:\s/i && /^[-A-Za-z]+:\s+\S/) {
>  				push @xh, $_;
>  			}

```

## Nickolai Zeldovich, 2013-01-07 03:38

Subject: Re: [PATCH] git-send-email: treat field names as case-independent
Message-ID: <CADGQE7HTB+s2=PWhMZ=1BpU9nruhx5OBhKOY-ngdZJz=vC61uQ@mail.gmail.com>
URL: https://gitlist.dev/e/CADGQE7HTB%2Bs2%3DPWhMZ%3D1BpU9nruhx5OBhKOY-ngdZJz%3DvC61uQ%40mail.gmail.com
In-Reply-To: <7va9sllljh.fsf@alter.siamese.dyndns.org>

```
On Sun, Jan 6, 2013 at 10:27 PM, Junio C Hamano <gitster@pobox.com> wrote:
> While I think this patch is a sensible thing to do, I at the same
> time wonder who is writing "cc:" in the lowercase in the first
> place, and if that is one of our tools, we should fix that part as
> well.  Such a header would leak out to the payload given to the
> underlying sendmail, doesn't it?

In my case, I wrote the "cc:" headers by hand; it was not a result of
any automated tool.  (Yes, the header makes it into the message
payload.  This makes the bug all the more annoying: other people's
replies get cc:ed to the right address, but the original message never
gets sent there.)

Nickolai.

```

## Junio C Hamano, 2013-01-07 07:47

Subject: Re: [PATCH] git-send-email: treat field names as case-independent
Message-ID: <7vsj6djuyp.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vsj6djuyp.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CADGQE7HTB+s2=PWhMZ=1BpU9nruhx5OBhKOY-ngdZJz=vC61uQ@mail.gmail.com>

```
Nickolai Zeldovich <nickolai@csail.mit.edu> writes:

> On Sun, Jan 6, 2013 at 10:27 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> While I think this patch is a sensible thing to do, I at the same
>> time wonder who is writing "cc:" in the lowercase in the first
>> place, and if that is one of our tools, we should fix that part as
>> well.  Such a header would leak out to the payload given to the
>> underlying sendmail, doesn't it?
>
> In my case, I wrote the "cc:" headers by hand; it was not a result of
> any automated tool.

Ok, thanks for shrinking the list of things that worries me by one ;-)

```
