1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-05 11:46:10 +02:00

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 <krzysiek@podlesie.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Krzysztof Mazur 2012-11-22 19:12:09 +01:00 committed by Junio C Hamano
parent 831a488b76
commit 95c0d4b68a

View File

@ -831,12 +831,12 @@ sub extract_valid_address {
$address =~ s/^\s*<(.*)>\s*$/$1/;
if ($have_email_valid) {
return scalar Email::Valid->address($address);
} else {
# less robust/correct than the monster regexp in Email::Valid,
# but still does a 99% job, and one less dependency
$address =~ /($local_part_regexp\@$domain_regexp)/;
return $1;
}
# less robust/correct than the monster regexp in Email::Valid,
# but still does a 99% job, and one less dependency
return $1 if $address =~ /($local_part_regexp\@$domain_regexp)/;
return undef;
}
# Usually don't need to change anything below here.