Code

Don't dereference a strdup-returned NULL
[git.git] / git-send-email.perl
index 12ced288857c7531f964d2e08e9a7c3cc1136dbd..7c0c90bd21bbb009de81aa315bed1c947a32c423 100755 (executable)
@@ -154,8 +154,8 @@ if ($@) {
        $term = new FakeTerm "$@: going non-interactive";
 }
 
-my $def_chain = $repo->config_boolean('sendemail.chainreplyto');
-if ($def_chain and $def_chain eq 'false') {
+my $def_chain = $repo->config_bool('sendemail.chainreplyto');
+if (defined $def_chain and not $def_chain) {
     $chain_reply_to = 0;
 }
 
@@ -212,7 +212,7 @@ my $aliasfiletype = $repo->config('sendemail.aliasfiletype');
 my %parse_alias = (
        # multiline formats can be supported in the future
        mutt => sub { my $fh = shift; while (<$fh>) {
-               if (/^alias\s+(\S+)\s+(.*)$/) {
+               if (/^\s*alias\s+(\S+)\s+(.*)$/) {
                        my ($alias, $addr) = ($1, $2);
                        $addr =~ s/#.*$//; # mutt allows # comments
                         # commas delimit multiple addresses
@@ -462,10 +462,13 @@ sub send_message
        }
 
        my $cc = join(", ", unique_email_list(@cc));
+       my $ccline = "";
+       if ($cc ne '') {
+               $ccline = "\nCc: $cc";
+       }
        $from = sanitize_address_rfc822($from);
        my $header = "From: $from
-To: $to
-Cc: $cc
+To: $to${ccline}
 Subject: $subject
 Date: $date
 Message-Id: $message_id
@@ -558,7 +561,8 @@ foreach my $t (@files) {
                                        $subject = $1;
 
                                } elsif (/^(Cc|From):\s+(.*)$/) {
-                                       if ($2 eq $from) {
+                                       if (unquote_rfc2047($2) eq $from) {
+                                               $from = $2;
                                                next if ($suppress_from);
                                        }
                                        elsif ($1 eq 'From') {