Skip to contentSkip to conversation

git send-email woes

DISCUSSION Sam Ravnborg 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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:

Quoted 10 lines
Quoted 10 lines

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 <[email protected]>
had couple quotes:
"Example J.P. Example" <[email protected]>

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

#1 lore raw
Quoted 19 lines · Sam Ravnborg

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:

Quoted 10 lines
Quoted 10 lines

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 <[email protected]>
had couple quotes:
"Example J.P. Example" <[email protected]>

Quoted 2 lines

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.

Quoted 6 lines

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

#2 lore raw
Quoted 3 lines · Sam Ravnborg

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?

git-send-email.perl +5 -0
index 746c525..b4a34f4 100755
@@ -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
#3 lore raw

From: Junio C Hamano <[email protected]>
Date: Mon, 25 Sep 2006 12:58:21 -0700

Quoted 10 lines
Quoted 3 lines · Sam Ravnborg

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.

#4 lore raw
In reply to Junio C Hamano
Quoted 18 lines · Junio C Hamano
Quoted 3 lines · Sam Ravnborg

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?

git-send-email.perl +0 -0
index 746c525..b4a34f4 100755
@@ -431,6 +431,11 @@ sub send_message
 	    $gitversion =~ s/^.* //;

git-send-email.perl sub send_message · line 441

Quoted 10 lines
git-send-email.perl +5 -0
 	}
 
+	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

#5 lore raw
Quoted 4 lines · Sam Ravnborg
Quoted 4 lines
git-send-email.perl +0 -0
@@ -431,6 +431,11 @@ sub send_message
 	    $gitversion =~ s/^.* //;
 	}
 
Quoted 11 lines

git-send-email.perl sub send_message · line 441

Quoted 9 lines
git-send-email.perl +5 -0
+	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 <[email protected]> => [email protected]

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...