Subject: Re: [PATCH 2/3] git send-email: do not ask questions when --compose is used.

From: Francis Galiegue <[email-masked]>
Date: Sat, 1 Nov 2008 20:56:37 +0100

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 "[^"]+(?:\\"[^"]*)*".

>   <[email-masked]>

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 <[email-masked]>, Random Joe <[email-masked]>, 
Superman <[email-masked]>, "Someone with a comma, inside its tag name" 
<[email-masked]>
To: [email-masked],
 [email-masked],
  [email-masked],
   [email-masked]
fg@erwin ~ $ perl t.pl <t.txt
Found mail: John Doe <[email-masked]>
Found mail: Random Joe <[email-masked]>
Found mail: Superman <[email-masked]>
Found mail: "Someone with a comma, inside its tag name" <[email-masked]>
Found mail: [email-masked]
Found mail: [email-masked]
Found mail: [email-masked]
Found mail: [email-masked]
----

-- 
fge