git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC PATCH 1/2] send-email: fix garbage removal after address

From
Matthieu Moy <git@matthieu-moy.fr>
Date
Aug 25, 2017, 09:11 UTC
Message-ID
<vpq378g107m.fsf@anie.imag.fr>
In-Reply-To
<xmqqk21svh9o.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> Matthieu Moy <git@matthieu-moy.fr> writes:
>
>> +sub strip_garbage_one_address {
>> +	my ($addr) = @_;
>> +	chomp $addr;
>> +	if ($addr =~ /^(("[^"]*"|[^"<]*)? *<[^>]*>).*/) {
>> +		# "Foo Bar" <foobar@example.com> [possibly garbage here]
>> +		# Foo Bar <foobar@example.com> [possibly garbage here]
>> +		return $1;
>> +	}
>> +	if ($addr =~ /^(<[^>]*>).*/) {
>> +		# <foo@example.com> [possibly garbage here]
>> +		# if garbage contains other addresses, they are ignored.
>> +		return $1;
>> +	}
>
> Isn't this already covered by the first one,

Oops, indeed. I just removed the second "if" (and added the appropriate comment to the first):

+       if ($addr =~ /^(("[^"]*"|[^"<]*)? *<[^>]*>).*/) {
+               # "Foo Bar" <foobar@example.com> [possibly garbage here]
+               # Foo Bar <foobar@example.com> [possibly garbage here]
+               # <foo@example.com> [possibly garbage here]
+               return $1;
+       }
Show 5 quoted lines
> By the way, these three regexps smell like they were written
> specifically to cover three cases you care about (perhaps the ones
> in your proposed log message), but what will be our response when
> somebody else comes next time to us and says that their favourite
> formatting of "Cc:" line is not covered by these rules?

Well, actually the last one covers essentially everything. Just stop at the first space, #, ',' or '"'. The first case is here to allow putting a name in front of the address, which is something we've already allowed and sounds reasonable from the user point of view.

OTOH, I didn't bother with real corner-cases like
  Cc: "Foo \"bar\"" <foobar@example.com>
Show 7 quoted lines
> So, from that point of view, I, with devil's advocate hat on, wonder
> why we are not saying
>
> 	"Cc: s@k.org # cruft"?  Use "Cc: <s@k.org> # cruft" instead
> 	and you'd be fine.
>
> right now, without this patch.

I would agree if the broken case were an exotic one. But a plain adress is really the simplest use-case I can think of, so it's hard to say "don't do that" when we should say "sorry, we should obviously have thought about this use-case".

-- 
Matthieu Moy
https://matthieu-moy.fr/
Previous: Junio C HamanoNext: Matthieu Moy
Message 10 of 13 in “git send-email Cc with cruft not working as expected”
  1. Jacob KellerAug 22, 2017
  2. Stefan BellerAug 22, 2017
  3. Jacob KellerAug 22, 2017
  4. Stefan BellerAug 22, 2017
  5. Matthieu MoyAug 23, 2017
  6. 1/2 send-email: fix garbage removal after addressMatthieu Moy, Aug 23, 2017
  7. 2/2 send-email: don't use Mail::Address, even if availableMatthieu Moy, Aug 23, 2017
  8. Jacob KellerAug 23, 2017
  9. Junio C HamanoAug 24, 2017
  10. Matthieu MoyAug 25, 2017
  11. 1/2 send-email: fix garbage removal after addressMatthieu Moy, Aug 25, 2017
  12. 2/2 send-email: don't use Mail::Address, even if availableMatthieu Moy, Aug 25, 2017
  13. Jacob KellerAug 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.