send-email: do not pass bogus address to local sendmail binary
This makes t9001 test happy. Also fixes the warning on uninitialized $references variable again. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
May 29, 2006 at 23:53 UTC
2186d566a6c2dfb2f168ae608bbb2e0e77122d7e
2 files changed
+17
-8
git-send-email.perl
+4
-2
@@ -387,7 +387,9 @@ X-Mailer: git-send-email $gitversion
387
my $pid = open my $sm, '|-';
388
defined $pid or die $!;
389
if (!$pid) {
390
- exec($smtp_server,'-i',@recipients) or die $!;
390
+ exec($smtp_server,'-i',
391
+ map { scalar extract_valid_address($_) }
392
+ @recipients) or die $!;
393
}
394
print $sm "$header\n$message";
395
close $sm or die $?;
@@ -420,7 +422,7 @@ X-Mailer: git-send-email $gitversion
422
}
423
424
$reply_to = $initial_reply_to;
423
-$references = $initial_reply_to;
425
+$references = $initial_reply_to || '';
426
make_message_id();
427
$subject = $initial_subject;
428
t/t9001-send-email.sh
+13
-6
@@ -13,10 +13,14 @@ test_expect_success \
13
14
test_expect_success \
15
'Setup helper tool' \
16
- 'echo "#!/bin/sh" > fake.sendmail
17
- echo "shift" >> fake.sendmail
18
- echo "echo \"\$*\" > commandline" >> fake.sendmail
19
- echo "cat > msgtxt" >> fake.sendmail
16
+ '(echo "#!/bin/sh"
17
+ echo shift
18
+ echo for a
19
+ echo do
20
+ echo " echo \"!\$a!\""
21
+ echo "done >commandline"
22
+ echo "cat > msgtxt"
23
+ ) >fake.sendmail
24
chmod +x ./fake.sendmail
25
git add fake.sendmail
26
GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
@@ -26,9 +30,12 @@ test_expect_success \
30
'git format-patch -n HEAD^1
31
git send-email -from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" ./0001*txt'
32
33
+cat >expected <<\EOF
34
+!nobody@example.com!
35
+!author@example.com!
36
+EOF
37
test_expect_success \
38
'Verify commandline' \
31
- 'cline=$(cat commandline)
32
- [ "$cline" == "nobody@example.com author@example.com" ]'
39
+ 'diff commandline expected'
40
41
test_done