From: Matthieu Moy <git@matthieu-moy.fr>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH 1/2] send-email: fix garbage removal after address
Date: Fri, 25 Aug 2017 11:11:09 +0200 [thread overview]
Message-ID: <vpq378g107m.fsf@anie.imag.fr> (raw)
In-Reply-To: <xmqqk21svh9o.fsf@gitster.mtv.corp.google.com> (Junio C. Hamano's message of "Thu, 24 Aug 2017 13:32:19 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> 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;
+ }
> 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>
> 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/
next prev parent reply other threads:[~2017-08-25 9:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 23:15 git send-email Cc with cruft not working as expected Jacob Keller
2017-08-22 23:18 ` Stefan Beller
2017-08-22 23:30 ` Jacob Keller
2017-08-22 23:36 ` Stefan Beller
2017-08-23 10:02 ` Matthieu Moy
2017-08-23 10:21 ` [RFC PATCH 1/2] send-email: fix garbage removal after address Matthieu Moy
2017-08-23 10:21 ` [RFC PATCH 2/2] send-email: don't use Mail::Address, even if available Matthieu Moy
2017-08-23 21:59 ` [RFC PATCH 1/2] send-email: fix garbage removal after address Jacob Keller
2017-08-24 20:32 ` Junio C Hamano
2017-08-25 9:11 ` Matthieu Moy [this message]
2017-08-25 9:11 ` [PATCH v2 " Matthieu Moy
2017-08-25 9:12 ` [PATCH v2 2/2] send-email: don't use Mail::Address, even if available Matthieu Moy
2017-08-23 22:49 ` git send-email Cc with cruft not working as expected Jacob Keller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpq378g107m.fsf@anie.imag.fr \
--to=git@matthieu-moy.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).