Subject: Re: [PATCH] git-send-email: fix handling of special characters

From: "Michael S. Tsirkin" <[email-masked]>
Date: Fri, 24 May 2013 00:19:54 +0300

On Thu, May 23, 2013 at 12:52:11PM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <[email-masked]> writes:
> 
> > When patch sender's name has special characters,
> > git send-email did not quote it before matching
> > against the author name.
> > As a result it would produce mail like this:
> >
> > 	Date: Thu, 23 May 2013 16:36:00 +0300
> > 	From: "Michael S. Tsirkin" <[email-masked]>
> > 	To: [email-masked]
> > 	Cc: "Michael S. Tsirkin" <[email-masked]>
> > 	Subject: [PATCH 0/9] virtio: switch to linux headers
> > 	Message-Id: <[email-masked]>
> >
> > 	From: "Michael S. Tsirkin" <[email-masked]>
> >
> > Fix by sanitizing before matching to patch author name.
> >
> > Signed-off-by: Michael S. Tsirkin <[email-masked]>
> > ---
> >  git-send-email.perl | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index bd13cc8..c4dc438 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -1400,7 +1400,8 @@ foreach my $t (@files) {
> >  		$subject = quote_subject($subject, $auto_8bit_encoding);
> >  	}
> >  
> > -	if (defined $author and $author ne $sender) {
> > +	my $sanitized_sender = sanitize_address($sender);
> > +	if (defined $author and $author ne $sanitized_sender) {
> >  		$message = "From: $author\n\n$message";
> >  		if (defined $author_encoding) {
> >  			if ($has_content_type) {
> 
> Is $author already sanitized at this point in the code?  I see it
> was unwrapped with unquote_rfc2047 after it was read from the From:
> line; will it always be the same as sanitize_address($author) would
> return, and if not, would you rather compare between sanitized
> versions of sender and author, no?

Yes. I'll have to look at the code more closely.
In my testing author here is "Michael S. Tsirkin" <[email-masked]>
so it matches the sanitized sender.
Of course that's because my name does not have non-ascii,
just a dot.

> Also, isn't the $sender the same during the whole outer loop that
> iterates over @files?  Do we need to apply sanitize_address() on it
> over and over for each and every logical line in the @header?
> 
> This comment also applies to the other patch but they probably
> should become a single patch anyway, I guess?

OK so now you are ok with this last bit, right?