{"thread":{"id":"48471","subject":"[BUG] git send-email: incorrectly parses email address with comma","startedAt":"2018-05-12T08:22:02Z","lastAt":"2018-05-12T21:10:04Z","messageCount":3,"participants":["Heinrich Schuchardt","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"347435","messageId":"9a35041b-8333-9533-4344-08d6ef99c9c9@gmx.de","threadId":"48471","inReplyTo":null,"subject":"[BUG] git send-email: incorrectly parses email address with comma","fromName":"Heinrich Schuchardt","fromEmail":"xypron.glpk@gmx.de","sentAt":"2018-05-12T08:21:46Z","receivedAt":"2018-05-12T08:22:02Z","isPatch":false,"sender":{"key":"xypron.glpk@gmx.de","avatar":"https://gravatar.com/avatar/ecfc545fcbe89519e2ffdf4eccf04756d830b2a7a26780b6f5b3d5d569d1d362?d=mp&s=160"},"body":"Git send-email allows to combine multiple email addresses in one\nparameter, e.g.\n\n--to=\"a@example.com, b@example.com\"\n\nBut email addresses may contain commas themselves:\n\n--to=\"LASTNAME, firstname <firstname.lastname@example.com>\"\n\nThis may lead to an error:\n$ git send-email --to=\"Schuchardt, Heinrich <xypron.glpk@example.com>\" \\\n0000*.patch0000-cover-letter.patch\n(mbox) Adding cc: Heinrich Schuchardt <xypron.glpk@example.com> from\nline 'From: Heinrich Schuchardt <xypron.glpk@example.com>'\n\nFrom: Heinrich Schuchardt <xypron.glpk@example.com>\nTo: Schuchardt,\n        Heinrich <xypron.glpk@example.com>\nSubject: [PATCH 0/2] efi_loader: adjust definitions of variable services\nDate: Sat, 12 May 2018 10:01:21 +0200\nMessage-Id: <20180512080121.26620-1-xypron.glpk@example.com>\nX-Mailer: git-send-email 2.17.0\n\nSend this email? ([y]es|[n]o|[q]uit|[a]ll): a\nPassword for 'smtp://xypron.glpk@example.com@mail.example.com:587':\nSyntax error in parameters or arguments\n\n\n\nPlease, implement the following logic,\n\nIf the string preceding a comma is not a valid email address do not\nsplit it off.\n\nBest regards\n\nHeinrich Schuchardt\n"},{"id":"347450","messageId":"20180512094849.GI28279@sigill.intra.peff.net","threadId":"48471","inReplyTo":"9a35041b-8333-9533-4344-08d6ef99c9c9@gmx.de","subject":"Re: [BUG] git send-email: incorrectly parses email address with comma","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-05-12T09:48:50Z","receivedAt":"2018-05-12T09:48:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, May 12, 2018 at 10:21:46AM +0200, Heinrich Schuchardt wrote:\n\n> Git send-email allows to combine multiple email addresses in one\n> parameter, e.g.\n> \n> --to=\"a@example.com, b@example.com\"\n> \n> But email addresses may contain commas themselves:\n> \n> --to=\"LASTNAME, firstname <firstname.lastname@example.com>\"\n> \n> This may lead to an error:\n\nIf the name contains syntactically relevant metacharacters, it can be\nquoted. So as a workaround, you can do:\n\n  --to='\"LASTNAME, firstname\" <firstname.lastname@example.com>'\n\nI think rfc822 actually requires even names with just spaces in them to\nbe quoted, but git-send-email and most other mail programs are pretty\nlax about allowing just about anything outside of the <>, so people tend\nnot to bother.\n\n> If the string preceding a comma is not a valid email address do not\n> split it off.\n\nThat might work as a heuristic, though \"is a valid email address\" is a\nnotoriously hard thing to check. Possibly looking for an \"@\" would catch\nmost common cases, though.\n\n-Peff\n"},{"id":"347474","messageId":"31d0ba6a-f681-53f8-b403-db833f0efa9b@gmx.de","threadId":"48471","inReplyTo":"20180512094849.GI28279@sigill.intra.peff.net","subject":"Re: [BUG] git send-email: incorrectly parses email address with comma","fromName":"Heinrich Schuchardt","fromEmail":"xypron.glpk@gmx.de","sentAt":"2018-05-12T21:07:50Z","receivedAt":"2018-05-12T21:10:04Z","isPatch":false,"sender":{"key":"xypron.glpk@gmx.de","avatar":"https://gravatar.com/avatar/ecfc545fcbe89519e2ffdf4eccf04756d830b2a7a26780b6f5b3d5d569d1d362?d=mp&s=160"},"body":"On 05/12/2018 11:48 AM, Jeff King wrote:\n> On Sat, May 12, 2018 at 10:21:46AM +0200, Heinrich Schuchardt wrote:\n> \n>> Git send-email allows to combine multiple email addresses in one\n>> parameter, e.g.\n>>\n>> --to=\"a@example.com, b@example.com\"\n>>\n>> But email addresses may contain commas themselves:\n>>\n>> --to=\"LASTNAME, firstname <firstname.lastname@example.com>\"\n>>\n>> This may lead to an error:\n> \n> If the name contains syntactically relevant metacharacters, it can be\n> quoted. So as a workaround, you can do:\n> \n>   --to='\"LASTNAME, firstname\" <firstname.lastname@example.com>'\n> \n> I think rfc822 actually requires even names with just spaces in them to\n> be quoted, but git-send-email and most other mail programs are pretty\n> lax about allowing just about anything outside of the <>, so people tend\n> not to bother.\n> \n>> If the string preceding a comma is not a valid email address do not\n>> split it off.\n> \n> That might work as a heuristic, though \"is a valid email address\" is a\n> notoriously hard thing to check. Possibly looking for an \"@\" would catch\n> most common cases, though.\n\nA more elaborate test would be:\nA string matching [\\S\\s]*<\\S+@\\S+.\\S+>\\s* is an email address.\nA string matching \\s*\\S+@\\S+.\\S+\\s* is an email address.\nBoth may need trimming of whitespace.\nAny other string is not an email address.\n\nRegards\n\nHeinrich\n\n> \n> -Peff\n> \n\n"}]}