>From 09ea51d63cebdf9ff0c073ef86e21b4b09c268e5 Mon Sep 17 00:00:00 2001 From: Michael Strawbridge <michael.strawbridge@xxxxxxx> Date: Wed, 11 Oct 2023 16:13:13 -0400 Subject: [PATCH] send-email: move validation code below process_address_list Move validation logic below processing of email address lists so that email validation gets the proper email addresses. This fixes email address validation errors when the optional perl module Email::Valid is installed and multiple addresses are passed in on a single to/cc argument like --to=foo@xxxxxxxxxxx,bar@xxxxxxxxxxx. Reported-by: Bagas Sanjaya <bagasdotme@xxxxxxxxx> Signed-off-by: Michael Strawbridge <michael.strawbridge@xxxxxxx> --- git-send-email.perl | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/git-send-email.perl b/git-send-email.perl index 288ea1ae80..a898dbc76e 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -799,30 +799,6 @@ sub is_format_patch_arg { $time = time - scalar $#files; -if ($validate) { - # FIFOs can only be read once, exclude them from validation. - my @real_files = (); - foreach my $f (@files) { - unless (-p $f) { - push(@real_files, $f); - } - } - - # Run the loop once again to avoid gaps in the counter due to FIFO - # arguments provided by the user. - my $num = 1; - my $num_files = scalar @real_files; - $ENV{GIT_SENDEMAIL_FILE_TOTAL} = "$num_files"; - foreach my $r (@real_files) { - $ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num"; - pre_process_file($r, 1); - validate_patch($r, $target_xfer_encoding); - $num += 1; - } - delete $ENV{GIT_SENDEMAIL_FILE_COUNTER}; - delete $ENV{GIT_SENDEMAIL_FILE_TOTAL}; -} - @files = handle_backup_files(@files); if (@files) { @@ -2023,6 +1999,30 @@ sub process_file { return 1; } +if ($validate) { + # FIFOs can only be read once, exclude them from validation. + my @real_files = (); + foreach my $f (@files) { + unless (-p $f) { + push(@real_files, $f); + } + } + + # Run the loop once again to avoid gaps in the counter due to FIFO + # arguments provided by the user. + my $num = 1; + my $num_files = scalar @real_files; + $ENV{GIT_SENDEMAIL_FILE_TOTAL} = "$num_files"; + foreach my $r (@real_files) { + $ENV{GIT_SENDEMAIL_FILE_COUNTER} = "$num"; + pre_process_file($r, 1); + validate_patch($r, $target_xfer_encoding); + $num += 1; + } + delete $ENV{GIT_SENDEMAIL_FILE_COUNTER}; + delete $ENV{GIT_SENDEMAIL_FILE_TOTAL}; +} + foreach my $t (@files) { while (!process_file($t)) { # user edited the file -- 2.42.0