git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-send-email: fix handling of special characters
@ 2013-05-23 13:54 Michael S. Tsirkin
  2013-05-23 19:52 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-05-23 13:54 UTC (permalink / raw)
  To: git

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" <mst@redhat.com>
	To: qemu-devel@nongnu.org
	Cc: "Michael S. Tsirkin" <mst@redhat.com>
	Subject: [PATCH 0/9] virtio: switch to linux headers
	Message-Id: <1369316169-20181-1-git-send-email-mst@redhat.com>

	From: "Michael S. Tsirkin" <mst@redhat.com>

Fix by sanitizing before matching to patch author name.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 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) {
-- 
MST

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-send-email: fix handling of special characters
  2013-05-23 13:54 [PATCH] git-send-email: fix handling of special characters Michael S. Tsirkin
@ 2013-05-23 19:52 ` Junio C Hamano
  2013-05-23 19:56   ` Junio C Hamano
  2013-05-23 21:19   ` Michael S. Tsirkin
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2013-05-23 19:52 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> 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" <mst@redhat.com>
> 	To: qemu-devel@nongnu.org
> 	Cc: "Michael S. Tsirkin" <mst@redhat.com>
> 	Subject: [PATCH 0/9] virtio: switch to linux headers
> 	Message-Id: <1369316169-20181-1-git-send-email-mst@redhat.com>
>
> 	From: "Michael S. Tsirkin" <mst@redhat.com>
>
> Fix by sanitizing before matching to patch author name.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  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?

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-send-email: fix handling of special characters
  2013-05-23 19:52 ` Junio C Hamano
@ 2013-05-23 19:56   ` Junio C Hamano
  2013-05-23 21:19   ` Michael S. Tsirkin
  1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2013-05-23 19:56 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

Junio C Hamano <gitster@pobox.com> writes:

>> +	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) {
>
> ...
> 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?

Ahh, I think $sender is constant, but this is not for each @header
line, but done per @file, so it is a much lessor offence than what I
originally thought.  The other one does do that inside the loop but
if we have a single copy of $sanitized_sender at the very beginning
that will become a non-issue.

> This comment also applies to the other patch but they probably
> should become a single patch anyway, I guess?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-send-email: fix handling of special characters
  2013-05-23 19:52 ` Junio C Hamano
  2013-05-23 19:56   ` Junio C Hamano
@ 2013-05-23 21:19   ` Michael S. Tsirkin
  2013-05-23 21:27     ` Junio C Hamano
  1 sibling, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-05-23 21:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, May 23, 2013 at 12:52:11PM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <mst@redhat.com> 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" <mst@redhat.com>
> > 	To: qemu-devel@nongnu.org
> > 	Cc: "Michael S. Tsirkin" <mst@redhat.com>
> > 	Subject: [PATCH 0/9] virtio: switch to linux headers
> > 	Message-Id: <1369316169-20181-1-git-send-email-mst@redhat.com>
> >
> > 	From: "Michael S. Tsirkin" <mst@redhat.com>
> >
> > Fix by sanitizing before matching to patch author name.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  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" <mst@redhat.com>
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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-send-email: fix handling of special characters
  2013-05-23 21:19   ` Michael S. Tsirkin
@ 2013-05-23 21:27     ` Junio C Hamano
  2013-05-23 21:38       ` Michael S. Tsirkin
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2013-05-23 21:27 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

>> 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" <mst@redhat.com>
> so it matches the sanitized sender.
> Of course that's because my name does not have non-ascii,
> just a dot.

So the conclusion is that the logic to see if the names are the same
needs a bit more work than what was posted, I think?

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

Sorry, but I am not sure what you are asking.

Do I think the assignment to $sanitized_sender can and should be
done just once, not once per file, if the code inspection tells us
that $sender is a constant inside the foreach (@files) loop?

Do I think these two are solving pretty much the same thing and is
better to be done in a single patch?  

I didn't really think them through when I responded, but now after
you made me think, I would say the answers to both of them are yes.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-send-email: fix handling of special characters
  2013-05-23 21:27     ` Junio C Hamano
@ 2013-05-23 21:38       ` Michael S. Tsirkin
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2013-05-23 21:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Thu, May 23, 2013 at 02:27:59PM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> >> 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" <mst@redhat.com>
> > so it matches the sanitized sender.
> > Of course that's because my name does not have non-ascii,
> > just a dot.
> 
> So the conclusion is that the logic to see if the names are the same
> needs a bit more work than what was posted, I think?

I think so. And a bit more testing with non-ASCII.
Plan to look into this around Sunday if no one beats me
to it.

> >> 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?
> 
> Sorry, but I am not sure what you are asking.
> 
> Do I think the assignment to $sanitized_sender can and should be
> done just once, not once per file, if the code inspection tells us
> that $sender is a constant inside the foreach (@files) loop?
> 
> Do I think these two are solving pretty much the same thing and is
> better to be done in a single patch?  
> 
> I didn't really think them through when I responded, but now after
> you made me think, I would say the answers to both of them are yes.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-05-23 21:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-23 13:54 [PATCH] git-send-email: fix handling of special characters Michael S. Tsirkin
2013-05-23 19:52 ` Junio C Hamano
2013-05-23 19:56   ` Junio C Hamano
2013-05-23 21:19   ` Michael S. Tsirkin
2013-05-23 21:27     ` Junio C Hamano
2013-05-23 21:38       ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).