ParseAddressList: return empty list if "" is provided

Go 1.15 handles "" in the address parser as a non error case, returning
an empty list.
Prior versions returned an error, which is not what we want.

Reported-by: anianz <a.ziegler@cioplenu.de>
Tested-by: anianz <a.ziegler@cioplenu.de>
This commit is contained in:
Reto Brunner 2020-08-24 23:01:18 +02:00
parent eb1439c241
commit b6ef116c36

View file

@ -21,6 +21,12 @@ func ParseAddress(address string) (*models.Address, error) {
}
func ParseAddressList(s string) ([]*models.Address, error) {
if len(s) == 0 {
// workaround for go versions < 1.15
// 1.15 returns an empty list if "" is provided as input, prior versions
// return an error which is not what we want
return nil, nil
}
parser := gomail.AddressParser{
&mime.WordDecoder{message.CharsetReader},
}