Skip to content

Commit 12288cc

Browse files
ttaylorrgitster
authored andcommitted
git-send-email.perl: avoid printing undef when validating addresses
When validating email addresses with `extract_valid_address_or_die()`, we print out a helpful error message when the given input does not contain a valid email address. However, the pre-image of this patch looks something like: my $address = shift; $address = extract_valid_address($address): die sprintf(__("..."), $address) if !$address; which fails when given a bogus email address by trying to use $address (which is undef) in a sprintf() expansion, like so: $ git.compile send-email --to="pi <pi@pi>" /tmp/x/*.patch --force Use of uninitialized value $address in sprintf at /home/ttaylorr/src/git/git-send-email line 1175. error: unable to extract a valid address from: This regression dates back to e431225 (git-send-email: remove invalid addresses earlier, 2012-11-22), but became more noticeable in a8022c5 (send-email: expose header information to git-send-email's sendemail-validate hook, 2023-04-19), which validates SMTP headers in the sendemail-validate hook. Avoid trying to format an undef by storing the given and cleaned address separately. After applying this fix, the error contains the invalid email address, and the warning disappears: $ git.compile send-email --to="pi <pi@pi>" /tmp/x/*.patch --force error: unable to extract a valid address from: pi <pi@pi> Reported-by: Bagas Sanjaya <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 43c8a30 commit 12288cc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

git-send-email.perl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,10 @@ sub extract_valid_address {
11661166
11671167
sub extract_valid_address_or_die {
11681168
my $address = shift;
1169-
$address = extract_valid_address($address);
1169+
my $valid_address = extract_valid_address($address);
11701170
die sprintf(__("error: unable to extract a valid address from: %s\n"), $address)
1171-
if !$address;
1172-
return $address;
1171+
if !$valid_address;
1172+
return $valid_address;
11731173
}
11741174
11751175
sub validate_address {

0 commit comments

Comments
 (0)