Merge branch 'bn/send-email-smtp-auth-error-message-fix'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Sep 2015 19:27:15 +0000 (12:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Sep 2015 19:27:15 +0000 (12:27 -0700)
Fix a minor regression brought in to "git send-email" by a recent
addition of the "--smtp-auth" option.

* bn/send-email-smtp-auth-error-message-fix:
send-email: fix uninitialized var warning for $smtp_auth

1  2 
git-send-email.perl
diff --combined git-send-email.perl
index c5a3f766f7fd34a48b352f3cfbb901840b4c4d5b,cfe26e5029f6376585d8e60f8886de1840d35200..e3ff44b4d0cd25f247138d9ead160d2aedff5033
@@@ -464,11 -464,25 +464,11 @@@ my ($repoauthor, $repocommitter)
  ($repoauthor) = Git::ident_person(@repo, 'author');
  ($repocommitter) = Git::ident_person(@repo, 'committer');
  
 -# Verify the user input
 -
 -foreach my $entry (@initial_to) {
 -      die "Comma in --to entry: $entry'\n" unless $entry !~ m/,/;
 -}
 -
 -foreach my $entry (@initial_cc) {
 -      die "Comma in --cc entry: $entry'\n" unless $entry !~ m/,/;
 -}
 -
 -foreach my $entry (@bcclist) {
 -      die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
 -}
 -
  sub parse_address_line {
        if ($have_mail_address) {
                return map { $_->format } Mail::Address->parse($_[0]);
        } else {
 -              return split_addrs($_[0]);
 +              return Git::parse_mailboxes($_[0]);
        }
  }
  
@@@ -551,6 -565,8 +551,6 @@@ if (@alias_files and $aliasfiletype an
        }
  }
  
 -($sender) = expand_aliases($sender) if defined $sender;
 -
  # is_format_patch_arg($f) returns 0 if $f names a patch, or 1 if
  # $f is a revision list specification to be passed to format-patch.
  sub is_format_patch_arg {
@@@ -795,10 -811,7 +795,10 @@@ if (!$force) 
        }
  }
  
 -if (!defined $sender) {
 +if (defined $sender) {
 +      $sender =~ s/^\s+|\s+$//g;
 +      ($sender) = expand_aliases($sender);
 +} else {
        $sender = $repoauthor || $repocommitter || '';
  }
  
@@@ -830,9 -843,12 +830,9 @@@ sub expand_one_alias 
        return $aliases{$alias} ? expand_aliases(@{$aliases{$alias}}) : $alias;
  }
  
 -@initial_to = expand_aliases(@initial_to);
 -@initial_to = validate_address_list(sanitize_address_list(@initial_to));
 -@initial_cc = expand_aliases(@initial_cc);
 -@initial_cc = validate_address_list(sanitize_address_list(@initial_cc));
 -@bcclist = expand_aliases(@bcclist);
 -@bcclist = validate_address_list(sanitize_address_list(@bcclist));
 +@initial_to = process_address_list(@initial_to);
 +@initial_cc = process_address_list(@initial_cc);
 +@bcclist = process_address_list(@bcclist);
  
  if ($thread && !defined $initial_reply_to && $prompting) {
        $initial_reply_to = ask(
@@@ -1025,17 -1041,15 +1025,17 @@@ sub sanitize_address 
                return $recipient;
        }
  
 +      # remove non-escaped quotes
 +      $recipient_name =~ s/(^|[^\\])"/$1/g;
 +
        # rfc2047 is needed if a non-ascii char is included
        if ($recipient_name =~ /[^[:ascii:]]/) {
 -              $recipient_name =~ s/^"(.*)"$/$1/;
                $recipient_name = quote_rfc2047($recipient_name);
        }
  
        # double quotes are needed if specials or CTLs are included
        elsif ($recipient_name =~ /[][()<>@,;:\\".\000-\037\177]/) {
 -              $recipient_name =~ s/(["\\\r])/\\$1/g;
 +              $recipient_name =~ s/([\\\r])/\\$1/g;
                $recipient_name = qq["$recipient_name"];
        }
  
@@@ -1047,14 -1061,6 +1047,14 @@@ sub sanitize_address_list 
        return (map { sanitize_address($_) } @_);
  }
  
 +sub process_address_list {
 +      my @addr_list = map { parse_address_line($_) } @_;
 +      @addr_list = expand_aliases(@addr_list);
 +      @addr_list = sanitize_address_list(@addr_list);
 +      @addr_list = validate_address_list(@addr_list);
 +      return @addr_list;
 +}
 +
  # Returns the local Fully Qualified Domain Name (FQDN) if available.
  #
  # Tightly configured MTAa require that a caller sends a real DNS
@@@ -1136,7 -1142,7 +1136,7 @@@ sub smtp_auth_maybe 
  
        # Check mechanism naming as defined in:
        # https://tools.ietf.org/html/rfc4422#page-8
-       if ($smtp_auth !~ /^(\b[A-Z0-9-_]{1,20}\s*)*$/) {
+       if ($smtp_auth && $smtp_auth !~ /^(\b[A-Z0-9-_]{1,20}\s*)*$/) {
                die "invalid smtp auth: '${smtp_auth}'";
        }
  
@@@ -1584,8 -1590,8 +1584,8 @@@ foreach my $t (@files) 
                ($confirm =~ /^(?:auto|compose)$/ && $compose && $message_num == 1));
        $needs_confirm = "inform" if ($needs_confirm && $confirm_unconfigured && @cc);
  
 -      @to = validate_address_list(sanitize_address_list(@to));
 -      @cc = validate_address_list(sanitize_address_list(@cc));
 +      @to = process_address_list(@to);
 +      @cc = process_address_list(@cc);
  
        @to = (@initial_to, @to);
        @cc = (@initial_cc, @cc);