threads / patch / 29543

patchsend-email: add extra safetly in address sanitazion

Subject: [PATCH] send-email: add extra safetly in address sanitazion

## tl;dr

4 messages between Feb 4, 2012 and Feb 5, 2012. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Felipe Contreras· Feb 4, 2012, 15:10 UTC · lore
Otherwise, 'git send-email' would be happy to do:
 % git send-email --to '<foo@bar.com>>'
And use '<foo@bar.com>>' in the headers.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to git-send-email.perl +1 −1
diff --git a/git-send-email.perl b/git-send-email.perl
index ef30c55..b8bf014 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -889,7 +889,7 @@ sub is_rfc2047_quoted {
 # use the simplest quoting being able to handle the recipient
 sub sanitize_address {
 	my ($recipient) = @_;
-	my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/);
+	my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*?>)/);
 
 	if (not $recipient_name) {
 		return $recipient;
-- 
1.7.9
Felipe Contreras· Feb 4, 2012, 15:26 UTC · re: Felipe Contreras · lore

Re: [PATCH] send-email: add extra safetly in address sanitazion

On Sat, Feb 4, 2012 at 5:10 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 5 quoted lines
> Otherwise, 'git send-email' would be happy to do:
>
>  % git send-email --to '<foo@bar.com>>'
>
> And use '<foo@bar.com>>' in the headers.

Er, actually that's not correct: '<foo@bar.com>>' will remain the same, but 'Foo <foo@bar.com>>' will be sanitized.

-- 
Felipe Contreras
Junio C Hamano· Feb 5, 2012, 21:12 UTC · re: Felipe Contreras · lore

Re: [PATCH] send-email: add extra safetly in address sanitazion

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 10 quoted lines
> On Sat, Feb 4, 2012 at 5:10 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> Otherwise, 'git send-email' would be happy to do:
>>
>>  % git send-email --to '<foo@bar.com>>'
>>
>> And use '<foo@bar.com>>' in the headers.
>
> Er, actually that's not correct: '<foo@bar.com>>' will remain the
> same, but 'Foo <foo@bar.com>>' will be sanitized.

I suspect that this "Er" is merely a sympotom of a larger issue in the approach taken by this patch. The code takes a potentially malformed input, and applies a rewrite logic without telling the user what it is doing. If the rewrite logic is perfect, that may be OK, but if not, the logic to rewrite may or may not trigger, or when it triggers it may or may not produce a correct result, and it all depends on the nature of breakage in the input.

Wouldn't a better approach to detect problem on the input side and reject a wrong one by erroring out, so that the user has a chance to fix?

Felipe Contreras· Feb 5, 2012, 21:20 UTC · re: Junio C Hamano · lore

Re: [PATCH] send-email: add extra safetly in address sanitazion

On Sun, Feb 5, 2012 at 11:12 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Sat, Feb 4, 2012 at 5:10 PM, Felipe Contreras
>> <felipe.contreras@gmail.com> wrote:
>>> Otherwise, 'git send-email' would be happy to do:
>>>
>>>  % git send-email --to '<foo@bar.com>>'
>>>
>>> And use '<foo@bar.com>>' in the headers.
>>
>> Er, actually that's not correct: '<foo@bar.com>>' will remain the
>> same, but 'Foo <foo@bar.com>>' will be sanitized.
>
> I suspect that this "Er" is merely a sympotom of a larger issue in the
> approach taken by this patch.  The code takes a potentially malformed
> input, and applies a rewrite logic without telling the user what it is
> doing.
That's what the function is doing already: sanitizing the address.
> Wouldn't a better approach to detect problem on the input side and reject
> a wrong one by erroring out, so that the user has a chance to fix?

Perhaps, but the code is not prepared for that. Anyway, feel free to drop it, I am not interested in pursing this.

Cheers.
-- 
Felipe Contreras

← back to recent threads