git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-send-email: Add --no-validate-email option
@ 2022-06-20  0:44 Stewart Smith
  2022-06-20  8:28 ` Ævar Arnfjörð Bjarmason
  2022-06-21  0:11 ` brian m. carlson
  0 siblings, 2 replies; 8+ messages in thread
From: Stewart Smith @ 2022-06-20  0:44 UTC (permalink / raw)
  To: git; +Cc: Stewart Smith, Todd Zullinger

The perl Email::Valid module gets things right, but this may not always
be what you want, as can be seen in
https://bugzilla.redhat.com/show_bug.cgi?id=2046203

So, add a --validate-email (default, current behavior) and
the inverse --no-validate-email option to be able to skip the check
while still having the Email::Valid perl module installed.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2046203
Suggested-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Stewart Smith <trawets@amazon.com>
---
 git-send-email.perl   | 9 +++++++++
 t/t9902-completion.sh | 1 +
 2 files changed, 10 insertions(+)

diff --git a/git-send-email.perl b/git-send-email.perl
index 5861e99a6e..c75b08f9ce 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -103,6 +103,7 @@ sub usage {
     --quiet                        * Output one line of info per email.
     --dry-run                      * Don't actually send the emails.
     --[no-]validate                * Perform patch sanity checks. Default on.
+    --[no-]validate-email          * Perform email address sanity checks. Default on.
     --[no-]format-patch            * understand any non optional arguments as
                                      `git format-patch` ones.
     --force                        * Send even if safety checks would prevent it.
@@ -281,6 +282,7 @@ sub do_edit {
 my $chain_reply_to = 0;
 my $use_xmailer = 1;
 my $validate = 1;
+my $validate_email = 1;
 my $target_xfer_encoding = 'auto';
 my $forbid_sendmail_variables = 1;
 
@@ -293,6 +295,7 @@ sub do_edit {
     "tocover" => \$cover_to,
     "signedoffcc" => \$signed_off_by_cc,
     "validate" => \$validate,
+    "validateemail" => \$validate_email,
     "multiedit" => \$multiedit,
     "annotate" => \$annotate,
     "xmailer" => \$use_xmailer,
@@ -531,6 +534,8 @@ sub config_regexp {
 		    "no-thread" => sub {$thread = 0},
 		    "validate!" => \$validate,
 		    "no-validate" => sub {$validate = 0},
+		    "validate-email!" => \$validate_email,
+		    "no-validate-email" => sub {$validate_email = 0},
 		    "transfer-encoding=s" => \$target_xfer_encoding,
 		    "format-patch!" => \$format_patch,
 		    "no-format-patch" => sub {$format_patch = 0},
@@ -1132,6 +1137,10 @@ sub extract_valid_address {
 	# check for a local address:
 	return $address if ($address =~ /^($local_part_regexp)$/);
 
+	# Email::Valid isn't always correct, so support a way to bypass
+	# See https://bugzilla.redhat.com/show_bug.cgi?id=2046203
+	return 1 if not $validate_email;
+
 	$address =~ s/^\s*<(.*)>\s*$/$1/;
 	my $have_email_valid = eval { require Email::Valid; 1 };
 	if ($have_email_valid) {
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 31526e6b64..6e363c46f3 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2302,6 +2302,7 @@ test_expect_success PERL 'send-email' '
 	EOF
 	test_completion "git send-email --val" <<-\EOF &&
 	--validate Z
+	--validate-email Z
 	EOF
 	test_completion "git send-email ma" "main "
 '
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-30 21:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-20  0:44 [PATCH] git-send-email: Add --no-validate-email option Stewart Smith
2022-06-20  8:28 ` Ævar Arnfjörð Bjarmason
2022-06-21  0:11 ` brian m. carlson
2022-06-21 16:00   ` Junio C Hamano
2022-06-21 22:12   ` Ævar Arnfjörð Bjarmason
2022-06-22  0:48     ` brian m. carlson
2022-06-30 11:18       ` Ævar Arnfjörð Bjarmason
2022-06-30 21:03         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).