# git send-email woes

6 messages from 2006-09-24 to 2006-09-26. Participants: Sam Ravnborg, Junio C Hamano, David Miller.
Thread: https://gitlist.dev/t/5679

## Sam Ravnborg, 2006-09-24 22:43

Subject: git send-email woes
Message-ID: <20060924224316.GA28051@uranus.ravnborg.org>
URL: https://gitlist.dev/e/20060924224316.GA28051%40uranus.ravnborg.org

```
I stumbled on two issues with git-send-email today.
First of I forgot to tell where to find the patch files to send.
But git-send-email only complained _after_ I had given all
the information manually.
It would have been niver to check that all mandatory arguments
was present before being interactive.

The second issue are best explained quoting a mail from Matti Arnio:
> > The GIT is at times producing emails that are not
> > utterly strictly speaking kosher RFC-(2)822 format.
> >
> > It might be a surprise to you that unquoted dots in
> > people's names cause syntax scanner indigestion,
> > because said character has very special meaning in
> > RFC-822 syntax.  All would be fine if
> >     Example J.P. Example <example@example.net>
> > had couple quotes:
> >     "Example J.P. Example" <example@example.net>

What I could see was that git-send-email takes mail address
verbatim from "Signed-off-by:" lines and use it.
Would it be possible to always quote it except when quoted
or to do a more intelligent RFC2822 check?

That would keep suprises lower.

I'm not good a perlish so I have not attempted fixing it myself...

	Sam

```

## Sam Ravnborg, 2006-09-25 18:32

Subject: Re: git send-email woes
Message-ID: <20060925183221.GE2490@uranus.ravnborg.org>
URL: https://gitlist.dev/e/20060925183221.GE2490%40uranus.ravnborg.org
In-Reply-To: <20060924224316.GA28051@uranus.ravnborg.org>

```
On Mon, Sep 25, 2006 at 12:43:16AM +0200, Sam Ravnborg wrote:
> I stumbled on two issues with git-send-email today.
> First of I forgot to tell where to find the patch files to send.
> But git-send-email only complained _after_ I had given all
> the information manually.
> It would have been niver to check that all mandatory arguments
> was present before being interactive.
> 
> The second issue are best explained quoting a mail from Matti Arnio:
> > > The GIT is at times producing emails that are not
> > > utterly strictly speaking kosher RFC-(2)822 format.
> > >
> > > It might be a surprise to you that unquoted dots in
> > > people's names cause syntax scanner indigestion,
> > > because said character has very special meaning in
> > > RFC-822 syntax.  All would be fine if
> > >     Example J.P. Example <example@example.net>
> > > had couple quotes:
> > >     "Example J.P. Example" <example@example.net>
> 
> What I could see was that git-send-email takes mail address
> verbatim from "Signed-off-by:" lines and use it.
The patches in quistion did not have a "Signed-off-by: tag so
that mail address has been from the author instead.
And this mail address was still invalid as per RFC2822.

> Would it be possible to always quote it except when quoted
> or to do a more intelligent RFC2822 check?
> 
> That would keep suprises lower.
> 
> I'm not good a perlish so I have not attempted fixing it myself...

	Sam

```

## Junio C Hamano, 2006-09-25 19:58

Subject: Re: git send-email woes
Message-ID: <7v7izrzpk2.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v7izrzpk2.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060925183221.GE2490@uranus.ravnborg.org>

```
Sam Ravnborg <sam@ravnborg.org> writes:

> The patches in quistion did not have a "Signed-off-by: tag so
> that mail address has been from the author instead.
> And this mail address was still invalid as per RFC2822.

I do not think it takes Signed-off-by: as author in any case
(and I do not think it should -- if it did so it is a bug).

Maybe something like this?

diff --git a/git-send-email.perl b/git-send-email.perl
index 746c525..b4a34f4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -431,6 +431,11 @@ sub send_message
 	    $gitversion =~ s/^.* //;
 	}
 
+	my ($author_name) = ($from =~ /^(.*?)\s+</);
+	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
+		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
+		$from = "\"$name\"$addr";
+	}
 	my $header = "From: $from
 To: $to
 Cc: $cc

```

## David Miller, 2006-09-25 21:17

Subject: Re: git send-email woes
Message-ID: <20060925.141740.122618728.davem@davemloft.net>
URL: https://gitlist.dev/e/20060925.141740.122618728.davem%40davemloft.net
In-Reply-To: <7v7izrzpk2.fsf@assigned-by-dhcp.cox.net>

```
From: Junio C Hamano <junkio@cox.net>
Date: Mon, 25 Sep 2006 12:58:21 -0700

> Sam Ravnborg <sam@ravnborg.org> writes:
> 
> > The patches in quistion did not have a "Signed-off-by: tag so
> > that mail address has been from the author instead.
> > And this mail address was still invalid as per RFC2822.
> 
> I do not think it takes Signed-off-by: as author in any case
> (and I do not think it should -- if it did so it is a bug).
> 
> Maybe something like this?

That looks like it would do the trick.

```

## Sam Ravnborg, 2006-09-25 21:51

Subject: Re: git send-email woes
Message-ID: <20060925215127.GA3965@uranus.ravnborg.org>
URL: https://gitlist.dev/e/20060925215127.GA3965%40uranus.ravnborg.org
In-Reply-To: <7v7izrzpk2.fsf@assigned-by-dhcp.cox.net>

```
On Mon, Sep 25, 2006 at 12:58:21PM -0700, Junio C Hamano wrote:
> Sam Ravnborg <sam@ravnborg.org> writes:
> 
> > The patches in quistion did not have a "Signed-off-by: tag so
> > that mail address has been from the author instead.
> > And this mail address was still invalid as per RFC2822.
> 
> I do not think it takes Signed-off-by: as author in any case
> (and I do not think it should -- if it did so it is a bug).
> 
> Maybe something like this?
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 746c525..b4a34f4 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -431,6 +431,11 @@ sub send_message
>  	    $gitversion =~ s/^.* //;
>  	}
>  
> +	my ($author_name) = ($from =~ /^(.*?)\s+</);
> +	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
> +		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
> +		$from = "\"$name\"$addr";
> +	}
>  	my $header = "From: $from
>  To: $to
>  Cc: $cc
> 
I would assume we had to do the same for all mail addresses?
In this case also for $to and $cc and $reply_to.

	Sam

```

## Junio C Hamano, 2006-09-26 04:11

Subject: Re: git send-email woes
Message-ID: <7vvenbuv0t.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvenbuv0t.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060925215127.GA3965@uranus.ravnborg.org>

```
Sam Ravnborg <sam@ravnborg.org> writes:

>> @@ -431,6 +431,11 @@ sub send_message
>>  	    $gitversion =~ s/^.* //;
>>  	}
>>  
>> +	my ($author_name) = ($from =~ /^(.*?)\s+</);
>> +	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
>> +		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
>> +		$from = "\"$name\"$addr";
>> +	}
>>  	my $header = "From: $from
>>  To: $to
>>  Cc: $cc
>> 
> I would assume we had to do the same for all mail addresses?
> In this case also for $to and $cc and $reply_to.

I do not think so, although I admit I only had a cursory look at
the code.  In this part of the code, $to and $cc are coming from
return value of unique_email_list sub, which cleanses each
address with extract_valid_address sub.  This sub does:

	A U Thor <foo@bar.baz> => foo@bar.baz

In other words, I think it is only "$from" that needs it.

I think $to and $cc should not strip out the human-readable name,
but in this case it saved us extra trouble.   Sigh...

```
