{"thread":{"id":"41723","subject":"One whitespace breaks sending mail (using mailrc aliases wit send-emal)","startedAt":"2016-03-17T01:28:59Z","lastAt":"2016-03-17T18:00:41Z","messageCount":4,"participants":["Stefan Beller","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"280994","messageId":"CAGZ79kbRdPMkbs_-BGhCQ44hOsccG3aX16RJpE3ZHcBmDz40zQ@mail.gmail.com","threadId":"41723","inReplyTo":null,"subject":"One whitespace breaks sending mail (using mailrc aliases wit send-emal)","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-03-17T01:28:59Z","receivedAt":"2016-03-17T01:28:59Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"To reproduce:\n\n$ git config sendemail.aliasesfile ~/.mailrc\n$ git config sendemail.aliasfiletype mailrc\n$ echo \"alias zzz_wrong_entry jon@do.e \"\n# notice the white space at the end of the alias\n\n$ git send-email 0001-rebase-x-do-not-die-without-i.patch --cc=zzz_wrong_entry\nUse of uninitialized value $alias in hash element at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n847.\nUse of uninitialized value $alias in hash element at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n850.\nUse of uninitialized value $alias in hash element at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n850.\nUse of uninitialized value $alias in hash element at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n850.\nUse of uninitialized value $alias in hash element at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n851.\nUse of uninitialized value $recipient in substitution (s///) at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n1036.\nUse of uninitialized value $recipient in pattern match (m//) at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n1038.\nUse of uninitialized value $address in pattern match (m//) at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n894.\nUse of uninitialized value $address in substitution (s///) at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n896.\nUse of uninitialized value $params[0] in pattern match (m//) at\n/usr/share/perl5/Email/Valid.pm line 79.\nUse of uninitialized value $address in concatenation (.) or string at\n/usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n918.\nerror: unable to extract a valid address from:\nWhat to do with this address? ([q]uit|[d]rop|[e]dit):\n\nThe stack trace doesn't even show the wrong address, so debugging that was hard.\nNot sure I am asking for help, as I found the problem and could fix\nit, but maybe we can\nimprove the error message (I have no knowledge about perl, so I may\nnot be super helpful there)\n\nThanks,\nStefan\n"},{"id":"280997","messageId":"20160317020015.GC12830@sigill.intra.peff.net","threadId":"41723","inReplyTo":"CAGZ79kbRdPMkbs_-BGhCQ44hOsccG3aX16RJpE3ZHcBmDz40zQ@mail.gmail.com","subject":"Re: One whitespace breaks sending mail (using mailrc aliases wit send-emal)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-03-17T02:00:15Z","receivedAt":"2016-03-17T02:00:15Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Mar 16, 2016 at 06:28:59PM -0700, Stefan Beller wrote:\n\n> To reproduce:\n> \n> $ git config sendemail.aliasesfile ~/.mailrc\n> $ git config sendemail.aliasfiletype mailrc\n> $ echo \"alias zzz_wrong_entry jon@do.e \"\n> # notice the white space at the end of the alias\n> \n> $ git send-email 0001-rebase-x-do-not-die-without-i.patch --cc=zzz_wrong_entry\n> Use of uninitialized value $alias in hash element at\n> /usr/local/google/home/sbeller/libexec/git-core/git-send-email line\n> 847.\n> [...]\n> The stack trace doesn't even show the wrong address, so debugging that was hard.\n> Not sure I am asking for help, as I found the problem and could fix\n> it, but maybe we can\n> improve the error message (I have no knowledge about perl, so I may\n> not be super helpful there)\n\nI don't think so. The problem is that we return `undef` for one of the\naliases, and then later when we look at that, perl obviously is unhappy.\nIt's sort of the equivalent of a C program dereferencing NULL, but the\nbug is assigning NULL in the first place much earlier.\n\nYou _can_ tell perl not to bother warning about accessing undef like\nthis, but it's usually a good idea to have such warnings on, as they are\nhelpful for finding real bugs.\n\nI imagine your problem is by:\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d356901..c45b22a 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -533,7 +533,7 @@ my %parse_alias = (\n \t\t\t$aliases{$alias} = \\@addr\n \t\t}}},\n \tmailrc => sub { my $fh = shift; while (<$fh>) {\n-\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*?)\\s*$/) {\n \t\t\t# spaces delimit multiple addresses\n \t\t\t$aliases{$1} = [ quotewords('\\s+', 0, $2) ];\n \t\t}}},\n\nto suppress the extra whitespace at the end (alternatively, there may be\na way to tell quotewords() to throw out a trailing delimiter, but I\ndon't know the Text::ParseWords module well enough to say offhand).\n\n-Peff\n"},{"id":"281057","messageId":"1458236870-23464-1-git-send-email-sbeller@google.com","threadId":"41723","inReplyTo":"20160317020015.GC12830@sigill.intra.peff.net","subject":"[PATCH] That works","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-03-17T17:47:50Z","receivedAt":"2016-03-17T17:47:50Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"sent from git-send-email with a corrupt .mailrc file.\n\nThanks,\nStefan\n\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex d356901..c45b22a 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -533,7 +533,7 @@ my %parse_alias = (\n \t\t\t$aliases{$alias} = \\@addr\n \t\t}}},\n \tmailrc => sub { my $fh = shift; while (<$fh>) {\n-\t\tif (/^alias\\s+(\\S+)\\s+(.*)$/) {\n+\t\tif (/^alias\\s+(\\S+)\\s+(.*?)\\s*$/) {\n \t\t\t# spaces delimit multiple addresses\n \t\t\t$aliases{$1} = [ quotewords('\\s+', 0, $2) ];\n \t\t}}},\n"},{"id":"281059","messageId":"20160317180041.GA18216@sigill.intra.peff.net","threadId":"41723","inReplyTo":"1458236870-23464-1-git-send-email-sbeller@google.com","subject":"Re: [PATCH] That works","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-03-17T18:00:41Z","receivedAt":"2016-03-17T18:00:41Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Mar 17, 2016 at 10:47:50AM -0700, Stefan Beller wrote:\n\n> sent from git-send-email with a corrupt .mailrc file.\n\nGreat, but could probably use a better commit message. ;P\n\n-Peff\n"}]}