1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

aliases: Treat empty pipe aliases as bad lines and skip them

A pipe alias must have a command, if it doesn't, we should treat the
line as bad and skip it like we do for others.
This commit is contained in:
Alberto Bertogli
2019-10-22 22:05:52 +01:00
parent 5f72f723db
commit dea6f73164
2 changed files with 8 additions and 0 deletions

View File

@@ -307,6 +307,10 @@ func parseReader(domain string, r io.Reader) (map[string][]Recipient, error) {
if rawalias[0] == '|' {
cmd := strings.TrimSpace(rawalias[1:])
if cmd == "" {
// A pipe alias without a command is invalid.
continue
}
aliases[addr] = []Recipient{{cmd, PIPE}}
} else {
rs := []Recipient{}

View File

@@ -198,6 +198,10 @@ func TestAddFile(t *testing.T) {
{"a: c@d, e@f, g\n",
[]Recipient{{"c@d", EMAIL}, {"e@f", EMAIL}, {"g@dom", EMAIL}}},
// Invalid pipe aliases, should be ignored.
{"a:|\n", []Recipient{{"a@dom", EMAIL}}},
{"a:| \n", []Recipient{{"a@dom", EMAIL}}},
}
for _, c := range cases {