Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-05-01 17:38:48 +0300
committerJunio C Hamano <gitster@pobox.com>2023-05-01 18:55:52 +0300
commit3a7a18a045cd94a13ed04ef715dcd1b91547a0af (patch)
tree4feb6783d5fa37d05972f4037ed85cd5faf761cf /git-send-email.perl
parentba92106e93c66e41af5180ac1b6ad0f959f72bb4 (diff)
send-email: detect empty blank lines in command output
The email format does not allow blank lines in headers; detect such input and report it as malformed and add a test for it. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl12
1 files changed, 10 insertions, 2 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index 32febe9af3..22a64e608f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -2026,14 +2026,22 @@ foreach my $t (@files) {
}
}
-# Execute a command and return its output lines as an array.
+# Execute a command and return its output lines as an array. Blank
+# lines which do not appear at the end of the output are reported as
+# errors.
sub execute_cmd {
my ($prefix, $cmd, $file) = @_;
my @lines = ();
+ my $seen_blank_line = 0;
open my $fh, "-|", "$cmd \Q$file\E"
or die sprintf(__("(%s) Could not execute '%s'"), $prefix, $cmd);
while (my $line = <$fh>) {
- last if $line =~ /^$/;
+ die sprintf(__("(%s) Malformed output from '%s'"), $prefix, $cmd)
+ if $seen_blank_line;
+ if ($line =~ /^$/) {
+ $seen_blank_line = $line =~ /^$/;
+ next;
+ }
push @lines, $line;
}
close $fh