mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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>
This commit is contained in:
committed by
Junio C Hamano
parent
ba92106e93
commit
3a7a18a045
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user