[PATCH 7/9] send-email: implement sendmail aliases line continuation support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Logical lines in sendmail aliases files can be spread over multiple
physical lines[1]. A line beginning with whitespace is folded into the
preceding line. A line ending with '\' consumes the following line.

[1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5

Signed-off-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
---

This implementation silently and "sanely" tolerates continuation line
scenarios for which behavior is not defined by [1]. In particular, an
indented line which is the first (non-comment) line in the file is
treated as a single logical line. Ditto for a line ending with '\' which
is the last (non-comment) line in the file.

An earlier iteration emitted warnings for such cases, but it wasn't
clear if warning about undefined behavior was useful; and it made the
implementation much more noisy, so this version silently tolerates such
anomalies.

 Documentation/git-send-email.txt |  2 --
 git-send-email.perl              | 10 +++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index e6d466e..7ae467b 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -394,8 +394,6 @@ described below:
 sendmail;;
 *	Quoted aliases and quoted addresses are not supported: lines that
 	contain a `"` symbol are ignored.
-*	Line continuations are not supported: lines that start with
-	whitespace characters, or end with a `\` symbol are ignored.
 *	Redirection to a file (`/path/name`) or pipe (`|command`) is not
 	supported.
 *	File inclusion (`:include: /path/name`) is not supported.
diff --git a/git-send-email.perl b/git-send-email.perl
index e777bd3..eb1d678 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -492,8 +492,6 @@ sub parse_sendmail_alias {
 	local $_ = shift;
 	if (/"/) {
 		print STDERR "warning: sendmail alias with quotes is not supported: $_\n";
-	} elsif (/^\s|\\$/) {
-		print STDERR "warning: sendmail continuation line is not supported: $_\n";
 	} elsif (/^(\S+?)\s*:\s*(.+)$/) {
 		my ($alias, $addr) = ($1, $2);
 		$aliases{$alias} = [ split_addrs($addr) ];
@@ -504,10 +502,16 @@ sub parse_sendmail_alias {
 
 sub parse_sendmail_aliases {
 	my $fh = shift;
+	my $s = '';
 	while (<$fh>) {
+		chomp;
 		next if /^\s*$/ || /^\s*#/;
-		parse_sendmail_alias($_);
+		$s .= $_, next if $s =~ s/\\$// || s/^\s+//;
+		parse_sendmail_alias($s) if $s;
+		$s = $_;
 	}
+	$s =~ s/\\$//; # silently tolerate stray '\' on last line
+	parse_sendmail_alias($s) if $s;
 }
 
 my %parse_alias = (
-- 
2.4.2.538.g5f4350e

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]