composer: remove header if empty

Remove a header when it is empty.

Commit a253e89bda ("compose: prevent sending empty address list
headers") tried to avoid sending empty headers; but instead of deleting
the header, the empty string value was just ignored.

Fixes: https://todo.sr.ht/~rjarry/aerc/55
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
This commit is contained in:
Koni Marti 2022-07-07 17:43:29 +02:00 committed by Robin Jarry
parent 635530b12d
commit aae46c7afd
1 changed files with 2 additions and 1 deletions

View File

@ -974,7 +974,8 @@ func (he *headerEditor) storeValue() {
switch strings.ToLower(he.name) {
case "to", "from", "cc", "bcc":
if strings.TrimSpace(val) == "" {
// Don't set empty address list headers
// if header is empty, delete it
he.header.Del(he.name)
return
}
list, err := mail.ParseAddressList(val)