git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-send-email: don't return undefined value in extract_valid_address()

From
KMKrzysztof Mazur <krzysiek@podlesie.net>
Date
Nov 20, 2012, 12:20 UTC
Message-ID
<1353414053-25261-1-git-send-email-krzysiek@podlesie.net>

In the fallback check, when Email::Valid is not available, the extract_valid_address() does not check for success of matching regex, and $1, which can be undefined, is always returned. Now if match fails an empty string is returned.

Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
---
This fixes following warnings:
Use of uninitialized value in string eq at ./git-send-email.perl line 1017.
Use of uninitialized value in quotemeta at ./git-send-email.perl line 1017.
W: unable to extract a valid address from: x a.patch

when invalid email address was added by --cc-cmd, ./git-send-email.perl --dry-run --to a@podlesie.net --cc-cmd=echo x a.patch

 git-send-email.perl | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 5a7c29d..045f25f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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 "";
 }
 
 # Usually don't need to change anything below here.
-- 
1.8.0.283.gc57d856
Next: Junio C Hamano
Message 1 of 4 in “git-send-email: don't return undefined value in extract_valid_address()”
  1. git-send-email: don't return undefined value in extract_valid_address()Krzysztof Mazur, Nov 20, 2012
  2. Junio C HamanoNov 20, 2012
  3. Krzysztof MazurNov 20, 2012
  4. Junio C HamanoNov 20, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.