Skip to content

Commit 95c0d4b

Browse files
Krzysztof Mazurgitster
authored andcommitted
git-send-email: fix fallback code in extract_valid_address()
In the fallback check, used when Email::Valid is not available, the extract_valid_address() uses $1 without checking for success of matching regex. The $1 variable may still hold the result of previous match, which is the address when email address was in '<>' or be undefined otherwise. Now if match fails undefined value is always returned to indicate error. The same value is used by Email::Valid->address() in that case. Previously 'foo@bar' address was rejected by Email::Valid and fallback, but '<foo@bar>' was rejected by Email::Valid, but accepted by fallback. Signed-off-by: Krzysztof Mazur <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 831a488 commit 95c0d4b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

git-send-email.perl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,12 +831,12 @@ sub extract_valid_address {
831831
$address =~ s/^\s*<(.*)>\s*$/$1/;
832832
if ($have_email_valid) {
833833
return scalar Email::Valid->address($address);
834-
} else {
835-
# less robust/correct than the monster regexp in Email::Valid,
836-
# but still does a 99% job, and one less dependency
837-
$address =~ /($local_part_regexp\@$domain_regexp)/;
838-
return $1;
839834
}
835+
836+
# less robust/correct than the monster regexp in Email::Valid,
837+
# but still does a 99% job, and one less dependency
838+
return $1 if $address =~ /($local_part_regexp\@$domain_regexp)/;
839+
return undef;
840840
}
841841

842842
# Usually don't need to change anything below here.

0 commit comments

Comments
 (0)