Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.
- From
- Francis Galiegue <fg@one2team.net>
- Date
- Nov 1, 2008, 19:56 UTC
- Message-ID
- <200811012056.37220.fg@one2team.net>
- In-Reply-To
- <20081101174352.GG26229@artemis.corp>
Le Saturday 01 November 2008 18:43:52 Pierre Habouzit, vous avez écrit : [...]
> Your regex fails to parse: > > "Someone with a comma, and an escape double quote \" in its name"
Easy fix: replace "[^"]+" with "[^"]+(?:\\"[^"]*)*".
> <regex.cant.be.used.for.serious.parsing@i.told.you.so>
Oh yes. Regexes _are_ the way to do serious parsing. All MIME packages you will find floating around use regexes to parse mail headers correctly.
Granted, adhering to the RFC822 to the letter is rather hard. But I have a sample program here that can not only parse the escaped double quote, but also take account for the multiple line stuff and multiple headers of the same type where email addresse are valid (To:, Cc:, Bcc:). See attachment. Feel free to use the code.
----
fg@erwin ~ $ cat t.txt To: John Doe <some.address@some.tld>, Random Joe <random.joe@abc.def>, Superman <batman@nyc.us>, "Someone with a comma, inside its tag name" <a@b.com> To: bbr@one2team.com, u1@whatever.org, u2@wherever.ru, u3@blah.com fg@erwin ~ $ perl t.pl <t.txt Found mail: John Doe <some.address@some.tld> Found mail: Random Joe <random.joe@abc.def> Found mail: Superman <batman@nyc.us> Found mail: "Someone with a comma, inside its tag name" <a@b.com> Found mail: bbr@one2team.com Found mail: u1@whatever.org Found mail: u2@wherever.ru Found mail: u3@blah.com ----
-- fge