{"thread":{"id":"33909","subject":"[PATCH] git-send-email: fix handling of special characters","startedAt":"2013-05-23T13:54:18Z","lastAt":"2013-05-23T21:38:08Z","messageCount":6,"participants":["Michael S. Tsirkin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"218263","messageId":"20130523135418.GA20741@redhat.com","threadId":"33909","inReplyTo":null,"subject":"[PATCH] git-send-email: fix handling of special characters","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-23T13:54:18Z","receivedAt":"2013-05-23T13:54:18Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"When patch sender's name has special characters,\ngit send-email did not quote it before matching\nagainst the author name.\nAs a result it would produce mail like this:\n\n\tDate: Thu, 23 May 2013 16:36:00 +0300\n\tFrom: \"Michael S. Tsirkin\" <mst@redhat.com>\n\tTo: qemu-devel@nongnu.org\n\tCc: \"Michael S. Tsirkin\" <mst@redhat.com>\n\tSubject: [PATCH 0/9] virtio: switch to linux headers\n\tMessage-Id: <1369316169-20181-1-git-send-email-mst@redhat.com>\n\n\tFrom: \"Michael S. Tsirkin\" <mst@redhat.com>\n\nFix by sanitizing before matching to patch author name.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n git-send-email.perl | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex bd13cc8..c4dc438 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1400,7 +1400,8 @@ foreach my $t (@files) {\n \t\t$subject = quote_subject($subject, $auto_8bit_encoding);\n \t}\n \n-\tif (defined $author and $author ne $sender) {\n+\tmy $sanitized_sender = sanitize_address($sender);\n+\tif (defined $author and $author ne $sanitized_sender) {\n \t\t$message = \"From: $author\\n\\n$message\";\n \t\tif (defined $author_encoding) {\n \t\t\tif ($has_content_type) {\n-- \nMST\n"},{"id":"218303","messageId":"7vk3mpeaok.fsf@alter.siamese.dyndns.org","threadId":"33909","inReplyTo":"20130523135418.GA20741@redhat.com","subject":"Re: [PATCH] git-send-email: fix handling of special characters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-23T19:52:11Z","receivedAt":"2013-05-23T19:52:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> When patch sender's name has special characters,\n> git send-email did not quote it before matching\n> against the author name.\n> As a result it would produce mail like this:\n>\n> \tDate: Thu, 23 May 2013 16:36:00 +0300\n> \tFrom: \"Michael S. Tsirkin\" <mst@redhat.com>\n> \tTo: qemu-devel@nongnu.org\n> \tCc: \"Michael S. Tsirkin\" <mst@redhat.com>\n> \tSubject: [PATCH 0/9] virtio: switch to linux headers\n> \tMessage-Id: <1369316169-20181-1-git-send-email-mst@redhat.com>\n>\n> \tFrom: \"Michael S. Tsirkin\" <mst@redhat.com>\n>\n> Fix by sanitizing before matching to patch author name.\n>\n> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> ---\n>  git-send-email.perl | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index bd13cc8..c4dc438 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1400,7 +1400,8 @@ foreach my $t (@files) {\n>  \t\t$subject = quote_subject($subject, $auto_8bit_encoding);\n>  \t}\n>  \n> -\tif (defined $author and $author ne $sender) {\n> +\tmy $sanitized_sender = sanitize_address($sender);\n> +\tif (defined $author and $author ne $sanitized_sender) {\n>  \t\t$message = \"From: $author\\n\\n$message\";\n>  \t\tif (defined $author_encoding) {\n>  \t\t\tif ($has_content_type) {\n\nIs $author already sanitized at this point in the code?  I see it\nwas unwrapped with unquote_rfc2047 after it was read from the From:\nline; will it always be the same as sanitize_address($author) would\nreturn, and if not, would you rather compare between sanitized\nversions of sender and author, no?\n\nAlso, isn't the $sender the same during the whole outer loop that\niterates over @files?  Do we need to apply sanitize_address() on it\nover and over for each and every logical line in the @header?\n\nThis comment also applies to the other patch but they probably\nshould become a single patch anyway, I guess?\n"},{"id":"218304","messageId":"7vfvxdeahz.fsf@alter.siamese.dyndns.org","threadId":"33909","inReplyTo":"7vk3mpeaok.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-send-email: fix handling of special characters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-23T19:56:08Z","receivedAt":"2013-05-23T19:56:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> +\tmy $sanitized_sender = sanitize_address($sender);\n>> +\tif (defined $author and $author ne $sanitized_sender) {\n>>  \t\t$message = \"From: $author\\n\\n$message\";\n>>  \t\tif (defined $author_encoding) {\n>>  \t\t\tif ($has_content_type) {\n>\n> ...\n> Also, isn't the $sender the same during the whole outer loop that\n> iterates over @files?  Do we need to apply sanitize_address() on it\n> over and over for each and every logical line in the @header?\n\nAhh, I think $sender is constant, but this is not for each @header\nline, but done per @file, so it is a much lessor offence than what I\noriginally thought.  The other one does do that inside the loop but\nif we have a single copy of $sanitized_sender at the very beginning\nthat will become a non-issue.\n\n> This comment also applies to the other patch but they probably\n> should become a single patch anyway, I guess?\n"},{"id":"218312","messageId":"20130523211954.GD31421@redhat.com","threadId":"33909","inReplyTo":"7vk3mpeaok.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-send-email: fix handling of special characters","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-23T21:19:54Z","receivedAt":"2013-05-23T21:19:54Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"On Thu, May 23, 2013 at 12:52:11PM -0700, Junio C Hamano wrote:\n> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n> \n> > When patch sender's name has special characters,\n> > git send-email did not quote it before matching\n> > against the author name.\n> > As a result it would produce mail like this:\n> >\n> > \tDate: Thu, 23 May 2013 16:36:00 +0300\n> > \tFrom: \"Michael S. Tsirkin\" <mst@redhat.com>\n> > \tTo: qemu-devel@nongnu.org\n> > \tCc: \"Michael S. Tsirkin\" <mst@redhat.com>\n> > \tSubject: [PATCH 0/9] virtio: switch to linux headers\n> > \tMessage-Id: <1369316169-20181-1-git-send-email-mst@redhat.com>\n> >\n> > \tFrom: \"Michael S. Tsirkin\" <mst@redhat.com>\n> >\n> > Fix by sanitizing before matching to patch author name.\n> >\n> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> > ---\n> >  git-send-email.perl | 3 ++-\n> >  1 file changed, 2 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > index bd13cc8..c4dc438 100755\n> > --- a/git-send-email.perl\n> > +++ b/git-send-email.perl\n> > @@ -1400,7 +1400,8 @@ foreach my $t (@files) {\n> >  \t\t$subject = quote_subject($subject, $auto_8bit_encoding);\n> >  \t}\n> >  \n> > -\tif (defined $author and $author ne $sender) {\n> > +\tmy $sanitized_sender = sanitize_address($sender);\n> > +\tif (defined $author and $author ne $sanitized_sender) {\n> >  \t\t$message = \"From: $author\\n\\n$message\";\n> >  \t\tif (defined $author_encoding) {\n> >  \t\t\tif ($has_content_type) {\n> \n> Is $author already sanitized at this point in the code?  I see it\n> was unwrapped with unquote_rfc2047 after it was read from the From:\n> line; will it always be the same as sanitize_address($author) would\n> return, and if not, would you rather compare between sanitized\n> versions of sender and author, no?\n\nYes. I'll have to look at the code more closely.\nIn my testing author here is \"Michael S. Tsirkin\" <mst@redhat.com>\nso it matches the sanitized sender.\nOf course that's because my name does not have non-ascii,\njust a dot.\n\n> Also, isn't the $sender the same during the whole outer loop that\n> iterates over @files?  Do we need to apply sanitize_address() on it\n> over and over for each and every logical line in the @header?\n> \n> This comment also applies to the other patch but they probably\n> should become a single patch anyway, I guess?\n\nOK so now you are ok with this last bit, right?\n"},{"id":"218316","messageId":"7vtxltcrog.fsf@alter.siamese.dyndns.org","threadId":"33909","inReplyTo":"20130523211954.GD31421@redhat.com","subject":"Re: [PATCH] git-send-email: fix handling of special characters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-23T21:27:59Z","receivedAt":"2013-05-23T21:27:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n>> Is $author already sanitized at this point in the code?  I see it\n>> was unwrapped with unquote_rfc2047 after it was read from the From:\n>> line; will it always be the same as sanitize_address($author) would\n>> return, and if not, would you rather compare between sanitized\n>> versions of sender and author, no?\n>\n> Yes. I'll have to look at the code more closely.\n> In my testing author here is \"Michael S. Tsirkin\" <mst@redhat.com>\n> so it matches the sanitized sender.\n> Of course that's because my name does not have non-ascii,\n> just a dot.\n\nSo the conclusion is that the logic to see if the names are the same\nneeds a bit more work than what was posted, I think?\n\n>> Also, isn't the $sender the same during the whole outer loop that\n>> iterates over @files?  Do we need to apply sanitize_address() on it\n>> over and over for each and every logical line in the @header?\n>> \n>> This comment also applies to the other patch but they probably\n>> should become a single patch anyway, I guess?\n>\n> OK so now you are ok with this last bit, right?\n\nSorry, but I am not sure what you are asking.\n\nDo I think the assignment to $sanitized_sender can and should be\ndone just once, not once per file, if the code inspection tells us\nthat $sender is a constant inside the foreach (@files) loop?\n\nDo I think these two are solving pretty much the same thing and is\nbetter to be done in a single patch?  \n\nI didn't really think them through when I responded, but now after\nyou made me think, I would say the answers to both of them are yes.\n"},{"id":"218318","messageId":"20130523213808.GA1327@redhat.com","threadId":"33909","inReplyTo":"7vtxltcrog.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-send-email: fix handling of special characters","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-23T21:38:08Z","receivedAt":"2013-05-23T21:38:08Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"On Thu, May 23, 2013 at 02:27:59PM -0700, Junio C Hamano wrote:\n> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n> \n> >> Is $author already sanitized at this point in the code?  I see it\n> >> was unwrapped with unquote_rfc2047 after it was read from the From:\n> >> line; will it always be the same as sanitize_address($author) would\n> >> return, and if not, would you rather compare between sanitized\n> >> versions of sender and author, no?\n> >\n> > Yes. I'll have to look at the code more closely.\n> > In my testing author here is \"Michael S. Tsirkin\" <mst@redhat.com>\n> > so it matches the sanitized sender.\n> > Of course that's because my name does not have non-ascii,\n> > just a dot.\n> \n> So the conclusion is that the logic to see if the names are the same\n> needs a bit more work than what was posted, I think?\n\nI think so. And a bit more testing with non-ASCII.\nPlan to look into this around Sunday if no one beats me\nto it.\n\n> >> Also, isn't the $sender the same during the whole outer loop that\n> >> iterates over @files?  Do we need to apply sanitize_address() on it\n> >> over and over for each and every logical line in the @header?\n> >> \n> >> This comment also applies to the other patch but they probably\n> >> should become a single patch anyway, I guess?\n> >\n> > OK so now you are ok with this last bit, right?\n> \n> Sorry, but I am not sure what you are asking.\n> \n> Do I think the assignment to $sanitized_sender can and should be\n> done just once, not once per file, if the code inspection tells us\n> that $sender is a constant inside the foreach (@files) loop?\n> \n> Do I think these two are solving pretty much the same thing and is\n> better to be done in a single patch?  \n> \n> I didn't really think them through when I responded, but now after\n> you made me think, I would say the answers to both of them are yes.\n"}]}