{"thread":{"id":"9456","subject":"[PATCH 1/2] send-email: rfc822 forbids using <address@domain> without a non-empty \"phrase\"","startedAt":"2007-08-09T13:27:56Z","lastAt":"2007-08-09T13:27:58Z","messageCount":3,"participants":["Uwe Kleine-König"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"50320","messageId":"11866660781833-git-send-email-ukleinek@informatik.uni-freiburg.de","threadId":"9456","inReplyTo":null,"subject":"[PATCH 0/2] patches for send-email","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-09T13:27:56Z","receivedAt":"2007-08-09T13:27:56Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nthis series is mainly a last test for the second patch.\n\nThe first patch is just a resend for a mail I sent a earlier today.\n\nYou can fetch these on top of Junio's current next from \n\n\tgit://www.modarm9.com/gitsrc/pub/people/ukleinek/git.git\n\n(in case you fear not to be able to extract my name properly out of the mails\n(or I didn't manage to get them right) :-))\n\nBest regards,\nUwe\n"},{"id":"50319","messageId":"1186666080946-git-send-email-ukleinek@informatik.uni-freiburg.de","threadId":"9456","inReplyTo":"11866660781833-git-send-email-ukleinek@informatik.uni-freiburg.de","subject":"[PATCH 1/2] send-email: rfc822 forbids using <address@domain> without a non-empty \"phrase\"","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-09T13:27:57Z","receivedAt":"2007-08-09T13:27:57Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Email::Valid does respect this considering such a mailbox specification\ninvalid.  b06c6bc831cbb9e9eb82fd3ffd5a2b674cd940d0 addressed the issue, but\nonly if Email::Valid is available.\n\nSigned-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>\n---\n git-send-email.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 39e433b..a02ab96 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -408,8 +408,8 @@ sub extract_valid_address {\n \t# check for a local address:\n \treturn $address if ($address =~ /^($local_part_regexp)$/);\n \n+\t$address =~ s/^\\s*<(.*)>\\s*$/$1/;\n \tif ($have_email_valid) {\n-\t\t$address =~ s/^\\s*<(.*)>\\s*$/$1/;\n \t\treturn scalar Email::Valid->address($address);\n \t} else {\n \t\t# less robust/correct than the monster regexp in Email::Valid,\n-- \n1.5.3.rc3.943.g14c81\n"},{"id":"50321","messageId":"11866660821639-git-send-email-ukleinek@informatik.uni-freiburg.de","threadId":"9456","inReplyTo":"1186666080946-git-send-email-ukleinek@informatik.uni-freiburg.de","subject":"[PATCH 2/2] send-email: get all the quoting of realnames right","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-08-09T13:27:58Z","receivedAt":"2007-08-09T13:27:58Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"- when sending several mails I got a slightly different behaviour for the first\n  mail compared to the second to last one.  The reason is that $from was\n  assigned in line 608 and was not reset when beginning to handle the next\n  mail.\n\n- Email::Valid can only handle properly quoted real names, so quote arguments\n  to extract_valid_address.\n\nThis patch cleans up variable naming to better differentiate between sender of\nthe mail and it's author.\n\nSigned-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>\n---\n git-send-email.perl |   50 ++++++++++++++++++++++++--------------------------\n 1 files changed, 24 insertions(+), 26 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex a02ab96..69559b2 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -137,7 +137,7 @@ my $compose_filename = \".msg.$$\";\n \n # Variables we fill in automatically, or via prompting:\n my (@to,@cc,@initial_cc,@bcclist,@xh,\n-\t$initial_reply_to,$initial_subject,@files,$from,$compose,$time);\n+\t$initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);\n \n my $smtp_server;\n my $envelope_sender;\n@@ -179,7 +179,7 @@ if (!@bcclist or !$bcclist[0]) {\n # Begin by accumulating all the variables (defined above), that we will end up\n # needing, first, from the command line:\n \n-my $rc = GetOptions(\"from=s\" => \\$from,\n+my $rc = GetOptions(\"sender|from=s\" => \\$sender,\n                     \"in-reply-to=s\" => \\$initial_reply_to,\n \t\t    \"subject=s\" => \\$initial_subject,\n \t\t    \"to=s\" => \\@to,\n@@ -216,8 +216,8 @@ foreach my $entry (@bcclist) {\n \n # Now, let's fill any that aren't set in with defaults:\n \n-my ($author) = $repo->ident_person('author');\n-my ($committer) = $repo->ident_person('committer');\n+my ($repoauthor) = $repo->ident_person('author');\n+my ($repocommitter) = $repo->ident_person('committer');\n \n my %aliases;\n my @alias_files = $repo->config('sendemail.aliasesfile');\n@@ -254,17 +254,17 @@ if (@alias_files and $aliasfiletype and defined $parse_alias{$aliasfiletype}) {\n \t}\n }\n \n-($from) = expand_aliases($from) if defined $from;\n+($sender) = expand_aliases($sender) if defined $sender;\n \n my $prompting = 0;\n-if (!defined $from) {\n-\t$from = $author || $committer;\n+if (!defined $sender) {\n+\t$sender = $repoauthor || $repocommitter;\n \tdo {\n-\t\t$_ = $term->readline(\"Who should the emails appear to be from? [$from] \");\n+\t\t$_ = $term->readline(\"Who should the emails appear to be from? [$sender] \");\n \t} while (!defined $_);\n \n-\t$from = $_ if ($_);\n-\tprint \"Emails will be sent from: \", $from, \"\\n\";\n+\t$sender = $_ if ($_);\n+\tprint \"Emails will be sent from: \", $sender, \"\\n\";\n \t$prompting++;\n }\n \n@@ -330,7 +330,7 @@ if ($compose) {\n \t# effort to have it be unique\n \topen(C,\">\",$compose_filename)\n \t\tor die \"Failed to open for writing $compose_filename: $!\";\n-\tprint C \"From $from # This line is ignored.\\n\";\n+\tprint C \"From $sender # This line is ignored.\\n\";\n \tprintf C \"Subject: %s\\n\\n\", $initial_subject;\n \tprintf C <<EOT;\n GIT: Please enter your email below.\n@@ -433,11 +433,11 @@ sub make_message_id\n \tmy $date = time;\n \tmy $pseudo_rand = int (rand(4200));\n \tmy $du_part;\n-\tfor ($from, $committer, $author) {\n-\t\t$du_part = extract_valid_address($_);\n-\t\tlast if ($du_part ne '');\n+\tfor ($sender, $repocommitter, $repoauthor) {\n+\t\t$du_part = extract_valid_address(sanitize_address($_));\n+\t\tlast if (defined $du_part and $du_part ne '');\n \t}\n-\tif ($du_part eq '') {\n+\tif (not defined $du_part or $du_part eq '') {\n \t\tuse Sys::Hostname qw();\n \t\t$du_part = 'user@' . Sys::Hostname::hostname();\n \t}\n@@ -508,10 +508,10 @@ sub send_message\n \tif ($cc ne '') {\n \t\t$ccline = \"\\nCc: $cc\";\n \t}\n-\t$from = sanitize_address($from);\n+\tmy $sanitized_sender = sanitize_address($sender);\n \tmake_message_id();\n \n-\tmy $header = \"From: $from\n+\tmy $header = \"From: $sanitized_sender\n To: $to${ccline}\n Subject: $subject\n Date: $date\n@@ -528,7 +528,7 @@ X-Mailer: git-send-email $gitversion\n \t}\n \n \tmy @sendmail_parameters = ('-i', @recipients);\n-\tmy $raw_from = $from;\n+\tmy $raw_from = $sanitized_sender;\n \t$raw_from = $envelope_sender if (defined $envelope_sender);\n \t$raw_from = extract_valid_address($raw_from);\n \tunshift (@sendmail_parameters,\n@@ -565,7 +565,7 @@ X-Mailer: git-send-email $gitversion\n \t\t} else {\n \t\t\tprint \"Sendmail: $smtp_server \".join(' ',@sendmail_parameters).\"\\n\";\n \t\t}\n-\t\tprint \"From: $from\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n+\t\tprint \"From: $sanitized_sender\\nSubject: $subject\\nCc: $cc\\nTo: $to\\n\\n\";\n \t\tif ($smtp) {\n \t\t\tprint \"Result: \", $smtp->code, ' ',\n \t\t\t\t($smtp->message =~ /\\n([^\\n]+\\n)$/s), \"\\n\";\n@@ -582,7 +582,7 @@ $subject = $initial_subject;\n foreach my $t (@files) {\n \topen(F,\"<\",$t) or die \"can't open file $t\";\n \n-\tmy $author_not_sender = undef;\n+\tmy $author = undef;\n \t@cc = @initial_cc;\n \t@xh = ();\n \tmy $input_format = undef;\n@@ -604,12 +604,11 @@ foreach my $t (@files) {\n \t\t\t\t\t$subject = $1;\n \n \t\t\t\t} elsif (/^(Cc|From):\\s+(.*)$/) {\n-\t\t\t\t\tif (unquote_rfc2047($2) eq $from) {\n-\t\t\t\t\t\t$from = $2;\n+\t\t\t\t\tif (unquote_rfc2047($2) eq $sender) {\n \t\t\t\t\t\tnext if ($suppress_from);\n \t\t\t\t\t}\n \t\t\t\t\telsif ($1 eq 'From') {\n-\t\t\t\t\t\t$author_not_sender = $2;\n+\t\t\t\t\t\t$author = unquote_rfc2047($2);\n \t\t\t\t\t}\n \t\t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n \t\t\t\t\t\t$2, $_) unless $quiet;\n@@ -653,9 +652,8 @@ foreach my $t (@files) {\n \t\t}\n \t}\n \tclose F;\n-\tif (defined $author_not_sender) {\n-\t\t$author_not_sender = unquote_rfc2047($author_not_sender);\n-\t\t$message = \"From: $author_not_sender\\n\\n$message\";\n+\tif (defined $author) {\n+\t\t$message = \"From: $author\\n\\n$message\";\n \t}\n \n \n-- \n1.5.3.rc3.943.g14c81\n"}]}