From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
Although emitted to stderr, warnings from the sendmail aliases parser
are not visually distinguished as such, and thus can easily be
overlooked in the normal noisy send-email output.
Signed-off-by: Eric Sunshine <redacted>
---
This prepends lowercase "warning:" rather than uppercase since lowercase
is used elsewhere in git-send-email.perl for diagnostic message
prefixes.
git-send-email.perl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -522,12 +522,12 @@ my %parse_alias = (# warn on lines that contain quoteselsif(/"/){-printSTDERR"sendmail alias with quotes is not supported: $_\n";+printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";}# warn on lines that continueelsif(/^\s|\\$/){-printSTDERR"sendmail continuation line is not supported: $_\n";+printSTDERR"warning: sendmail continuation line is not supported: $_\n";}# recognize lines that look like an alias
@@ -538,7 +538,7 @@ my %parse_alias = (# warn on lines that are not recognizedelse{-printSTDERR"sendmail line is not recognized: $_\n";+printSTDERR"warning: sendmail line is not recognized: $_\n";}}},gnus=>sub{my$fh=shift;while(<$fh>){
@@ -517,26 +517,21 @@ my %parse_alias = (}},sendmail=>sub{my$fh=shift;while(<$fh>){-# ignore blank lines and comment linesif(/^\s*(?:#.*)?$/){}-# warn on lines that contain quoteselsif(/"/){printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";}-# warn on lines that continueelsif(/^\s|\\$/){printSTDERR"warning: sendmail continuation line is not supported: $_\n";}-# recognize lines that look like an aliaselsif(/^(\S+?)\s*:\s*(.+)$/){my($alias,$addr)=($1,$2);$aliases{$alias}=[split_addrs($addr)];}-# warn on lines that are not recognizedelse{printSTDERR"warning: sendmail line is not recognized: $_\n";}}},
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
Sendmail aliases[1] supports expansion to a file ("/path/name") or
pipe ("|command"), as well as file inclusion (":include: /path/name"),
however, our implementation does not support such functionality.
[1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5
Signed-off-by: Eric Sunshine <redacted>
---
Documentation/git-send-email.txt | 3 +++
1 file changed, 3 insertions(+)
@@ -396,6 +396,9 @@ sendmail;; 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. * Warnings are printed on the standard error output for any explicitly unsupported constructs, and any other lines that are not recognized by the parser.
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
Several new tests of sendmail aliases parsing will be added in a
subsequent patch, so factor out functionality common to all of them
into a new helper function.
Signed-off-by: Eric Sunshine <redacted>
---
t/t9001-send-email.sh | 47 +++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 18 deletions(-)
@@ -1549,10 +1549,35 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' 'grep"^!someone@example\.org!$"commandline1'-test_expect_success$PREREQ'sendemail.aliasfiletype=sendmail''-clean_fake_sendmail&&rm-froutdir&&-gitformat-patch-1-ooutdir&&-cat>>.tmp-email-aliases<<-\EOF&&+test_sendmail_aliases(){+msg="$1"&&shift&&+expect="$@"&&+cat>.tmp-email-aliases&&++test_expect_success$PREREQ"$msg"'+clean_fake_sendmail&&rm-froutdir&&+gitformat-patch-1-ooutdir&&+gitconfig--replace-allsendemail.aliasesfile\+"$(pwd)/.tmp-email-aliases"&&+gitconfigsendemail.aliasfiletypesendmail&&+gitsend-email\+--from="Example <nobody@example.com>"\+--to=alice--to=bcgrp\+--smtp-server="$(pwd)/fake.sendmail"\+outdir/0001-*.patch\+2>errors>out&&+foriin$expect+do+grep"^!$i!$"commandline1||return1+done+'+}++test_sendmail_aliases'sendemail.aliasfiletype=sendmail'\+'awol@example\.com'\+'bob@example\.com'\+'chloe@example\.com'\+'o@example\.com'<<-\EOFalice:AliceWLand<awol@example.com>bob:RobertBobbyton<bob@example.com># this is a comment
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
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 <redacted>
---
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(-)
@@ -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.
@@ -492,8 +492,6 @@ sub parse_sendmail_alias {local$_=shift;if(/"/){printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";-}elsif(/^\s|\\$/){-printSTDERR"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 {subparse_sendmail_aliases{my$fh=shift;+my$s='';while(<$fh>){+chomp;nextif/^\s*$/||/^\s*#/;-parse_sendmail_alias($_);+$s.=$_,nextif$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=(
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
The sendmail aliases parser inlined into %parse_alias is already
uncomfortably large and is expected to grow as additional functionality
is implemented, so extract it to improve manageability.
Signed-off-by: Eric Sunshine <redacted>
---
git-send-email.perl | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
@@ -487,6 +487,29 @@ sub split_addrs {}my%aliases;++subparse_sendmail_alias{+local$_=shift;+if(/"/){+printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";+}elsif(/^\s|\\$/){+printSTDERR"warning: sendmail continuation line is not supported: $_\n";+}elsif(/^(\S+?)\s*:\s*(.+)$/){+my($alias,$addr)=($1,$2);+$aliases{$alias}=[split_addrs($addr)];+}else{+printSTDERR"warning: sendmail line is not recognized: $_\n";+}+}++subparse_sendmail_aliases{+my$fh=shift;+while(<$fh>){+if(/^\s*(?:#.*)?$/){next;}+parse_sendmail_alias($_);+}+}+my%parse_alias=(# multiline formats can be supported in the futuremutt=>sub{my$fh=shift;while(<$fh>){
@@ -515,20 +538,7 @@ my %parse_alias = ($aliases{$alias}=[split_addrs($addr)];}}},--sendmail=>sub{my$fh=shift;while(<$fh>){-if(/^\s*(?:#.*)?$/){-}elsif(/"/){-printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";-}elsif(/^\s|\\$/){-printSTDERR"warning: sendmail continuation line is not supported: $_\n";-}elsif(/^(\S+?)\s*:\s*(.+)$/){-my($alias,$addr)=($1,$2);-$aliases{$alias}=[split_addrs($addr)];-}else{-printSTDERR"warning: sendmail line is not recognized: $_\n";-}}},-+sendmail=>\&parse_sendmail_aliases,gnus=>sub{my$fh=shift;while(<$fh>){if(/\(define-mail-alias\s+"(\S+?)"\s+"(\S+?)"\)/){$aliases{$1}=[$2];
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
Replace unnecessarily complex regular expression for recognizing comment
and blanks lines in sendmail aliases with idiomatic expressions which
can be easily understood at a glance.
Signed-off-by: Eric Sunshine <redacted>
---
git-send-email.perl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -517,22 +517,15 @@ my %parse_alias = (}},sendmail=>sub{my$fh=shift;while(<$fh>){-if(/^\s*(?:#.*)?$/){}--elsif(/"/){+if(/^\s*(?:#.*)?$/){+}elsif(/"/){printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";-}--elsif(/^\s|\\$/){+}elsif(/^\s|\\$/){printSTDERR"warning: sendmail continuation line is not supported: $_\n";-}--elsif(/^(\S+?)\s*:\s*(.+)$/){+}elsif(/^(\S+?)\s*:\s*(.+)$/){my($alias,$addr)=($1,$2);$aliases{$alias}=[split_addrs($addr)];-}--else{+}else{printSTDERR"warning: sendmail line is not recognized: $_\n";}}},
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
A line beginning with whitespace is folded into the preceding line.
A line ending with '\' consumes the following line.
While here, also test an empty sendmail aliases file.
Signed-off-by: Eric Sunshine <redacted>
---
t/t9001-send-email.sh | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:04
On Sun, May 31, 2015 at 6:29 PM, Eric Sunshine [off-list ref] wrote:
Replace unnecessarily complex regular expression for recognizing comment
and blanks lines in sendmail aliases with idiomatic expressions which
s/blanks/blank/
quoted hunk
can be easily understood at a glance.
Signed-off-by: Eric Sunshine <redacted>
---
git-send-email.perl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Allen Hubbe <allenbh@gmail.com> Date: 2016-06-15 23:05:04
According to the documentation, the parser should print a warning for
any explicitly unsupported constructs. These are now explicitly
unsupported, so the parser should warn on |, /, and :include: .
Perhaps the lines that match should be ignored like the others, too.
On Sun, May 31, 2015 at 6:29 PM, Eric Sunshine [off-list ref] wrote:
quoted hunk
Sendmail aliases[1] supports expansion to a file ("/path/name") or
pipe ("|command"), as well as file inclusion (":include: /path/name"),
however, our implementation does not support such functionality.
[1]: https://www.freebsd.org/cgi/man.cgi?query=aliases&sektion=5
Signed-off-by: Eric Sunshine <redacted>
---
Documentation/git-send-email.txt | 3 +++
1 file changed, 3 insertions(+)
@@ -396,6 +396,9 @@ sendmail;; 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. * Warnings are printed on the standard error output for any explicitly unsupported constructs, and any other lines that are not recognized by the parser.--
From: Allen Hubbe <allenbh@gmail.com> Date: 2016-06-15 23:05:04
This series looks very good to me. Thanks for the extra work you've
done to make the sendmail alias support much better :)
I'm not too concerned about this, but if you think it would be
appropriate you may use it:
Acked-by: Allen Hubbe <allenbh@gmail.com>
On Sun, May 31, 2015 at 6:29 PM, Eric Sunshine [off-list ref] wrote:
This series adds line continuation support for sendmail aliases.
It extends basic sendmail aliases functionality implemented by
ah/send-email-sendmail-alias (currently d1205b07 in 'pu')
Eric Sunshine (9):
send-email: further document missing sendmail aliases functionality
send-email: visually distinguish sendmail aliases parser warnings
send-email: drop noise comments which merely repeat what code says
send-email: fix style: cuddle 'elsif' and 'else' with closing brace
send-email: refactor sendmail aliases parser
send-email: simplify sendmail aliases comment and blank line
recognizer
send-email: implement sendmail aliases line continuation support
t9001: refactor sendmail aliases test infrastructure
t9001: add sendmail aliases line continuation tests
Documentation/git-send-email.txt | 5 ++-
git-send-email.perl | 54 ++++++++++++++-------------
t/t9001-send-email.sh | 81 +++++++++++++++++++++++++++++++---------
3 files changed, 94 insertions(+), 46 deletions(-)
--
2.4.2.538.g5f4350e
From: Eric Sunshine <hidden> Date: 2016-06-15 23:05:05
On Mon, Jun 01, 2015 at 07:43:08AM -0400, Allen Hubbe wrote:
On May 31, 2015 at 6:29 PM, Eric Sunshine [off-list ref] wrote:
quoted
Sendmail aliases[1] supports expansion to a file ("/path/name") or
pipe ("|command"), as well as file inclusion (":include: /path/name"),
however, our implementation does not support such functionality.
According to the documentation, the parser should print a warning for
any explicitly unsupported constructs. These are now explicitly
unsupported, so the parser should warn on |, /, and :include: .
Perhaps the lines that match should be ignored like the others, too.
Indeed. I had that in mind and then promptly forgot about it. Here's a
follow-on patch:
--- >8 ---
From: Eric Sunshine <redacted>
Subject: [PATCH 10/9] send-email: further warn about unsupported sendmail aliases features
The sendmail aliases parser diagnoses unsupported features and
unrecognized lines. For completeness, also warn about unsupported
redirection to "/path/name" and "|command", as well as ":include:".
Signed-off-by: Eric Sunshine <redacted>
---
git-send-email.perl | 4 ++++
1 file changed, 4 insertions(+)
@@ -492,6 +492,10 @@ sub parse_sendmail_alias {local$_=shift;if(/"/){printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";+}elsif(/:include:/){+printSTDERR"warning: `:include:` not supported: $_\n";+}elsif(/[\/|]/){+printSTDERR"warning: `/file` or `|pipe` redirection not supported: $_\n";}elsif(/^(\S+?)\s*:\s*(.+)$/){my($alias,$addr)=($1,$2);$aliases{$alias}=[split_addrs($addr)];
From: Allen Hubbe <allenbh@gmail.com> Date: 2016-06-15 23:05:05
This looks good.
On Mon, Jun 1, 2015 at 2:22 PM, Eric Sunshine [off-list ref] wrote:
quoted hunk
On Mon, Jun 01, 2015 at 07:43:08AM -0400, Allen Hubbe wrote:
quoted
On May 31, 2015 at 6:29 PM, Eric Sunshine [off-list ref] wrote:
quoted
Sendmail aliases[1] supports expansion to a file ("/path/name") or
pipe ("|command"), as well as file inclusion (":include: /path/name"),
however, our implementation does not support such functionality.
According to the documentation, the parser should print a warning for
any explicitly unsupported constructs. These are now explicitly
unsupported, so the parser should warn on |, /, and :include: .
Perhaps the lines that match should be ignored like the others, too.
Indeed. I had that in mind and then promptly forgot about it. Here's a
follow-on patch:
--- >8 ---
From: Eric Sunshine <redacted>
Subject: [PATCH 10/9] send-email: further warn about unsupported sendmail aliases features
The sendmail aliases parser diagnoses unsupported features and
unrecognized lines. For completeness, also warn about unsupported
redirection to "/path/name" and "|command", as well as ":include:".
Signed-off-by: Eric Sunshine <redacted>
---
git-send-email.perl | 4 ++++
1 file changed, 4 insertions(+)
@@ -492,6 +492,10 @@ sub parse_sendmail_alias {local$_=shift;if(/"/){printSTDERR"warning: sendmail alias with quotes is not supported: $_\n";+}elsif(/:include:/){+printSTDERR"warning: `:include:` not supported: $_\n";+}elsif(/[\/|]/){+printSTDERR"warning: `/file` or `|pipe` redirection not supported: $_\n";}elsif(/^(\S+?)\s*:\s*(.+)$/){my($alias,$addr)=($1,$2);$aliases{$alias}=[split_addrs($addr)];--