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

Re: [BUG] git send-email: incorrectly parses email address with comma

From
Heinrich Schuchardt <xypron.glpk@gmx.de>
Date
May 12, 2018, 21:07 UTC
Message-ID
<31d0ba6a-f681-53f8-b403-db833f0efa9b@gmx.de>
In-Reply-To
<20180512094849.GI28279@sigill.intra.peff.net>
On 05/12/2018 11:48 AM, Jeff King wrote:
Show 29 quoted lines
> On Sat, May 12, 2018 at 10:21:46AM +0200, Heinrich Schuchardt wrote:
> 
>> Git send-email allows to combine multiple email addresses in one
>> parameter, e.g.
>>
>> --to="a@example.com, b@example.com"
>>
>> But email addresses may contain commas themselves:
>>
>> --to="LASTNAME, firstname <firstname.lastname@example.com>"
>>
>> This may lead to an error:
> 
> If the name contains syntactically relevant metacharacters, it can be
> quoted. So as a workaround, you can do:
> 
>   --to='"LASTNAME, firstname" <firstname.lastname@example.com>'
> 
> I think rfc822 actually requires even names with just spaces in them to
> be quoted, but git-send-email and most other mail programs are pretty
> lax about allowing just about anything outside of the <>, so people tend
> not to bother.
> 
>> If the string preceding a comma is not a valid email address do not
>> split it off.
> 
> That might work as a heuristic, though "is a valid email address" is a
> notoriously hard thing to check. Possibly looking for an "@" would catch
> most common cases, though.

A more elaborate test would be: A string matching [\S\s]*<\S+@\S+.\S+>\s* is an email address. A string matching \s*\S+@\S+.\S+\s* is an email address. Both may need trimming of whitespace. Any other string is not an email address.

Regards
Heinrich
> 
> -Peff
> 
Previous: Jeff King
Message 3 of 3 in “[BUG] git send-email: incorrectly parses email address with comma”
  1. Heinrich SchuchardtMay 12, 2018
  2. Jeff KingMay 12, 2018
  3. Heinrich SchuchardtMay 12, 2018

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.