diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-09-28 23:18:42 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-09-29 16:51:53 +0200 |
commit | 684ceed2cdc66b34f8dcae97c641778c7117bb66 (patch) | |
tree | 4d5a21c570110bd79c24854b9cf91f072678c0b7 /worker | |
parent | 055c6dc6604f7f5ae7de060a36c81dc77801dca3 (diff) | |
download | aerc-684ceed2cdc66b34f8dcae97c641778c7117bb66.tar.gz |
lib: parse address header fields to utf-8
When parsing address header fields, the field charset is automatically
decoded to UTF-8. If the charset is unknown, use the raw field value.
Fixes: https://todo.sr.ht/~rjarry/aerc/91
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'worker')
-rw-r--r-- | worker/lib/parse.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/worker/lib/parse.go b/worker/lib/parse.go index 3eaa2aef..616784c6 100644 --- a/worker/lib/parse.go +++ b/worker/lib/parse.go @@ -225,15 +225,18 @@ func parseReceivedHeader(h *mail.Header) (time.Time, error) { } func parseAddressList(h *mail.Header, key string) ([]*mail.Address, error) { - addrs, err := h.AddressList(key) - if err == nil { - return addrs, nil - } hdr, err := h.Text(key) - if err != nil { + if err != nil && !message.IsUnknownCharset(err) { return nil, err } - return []*mail.Address{{Name: hdr}}, nil + if hdr == "" { + return nil, nil + } + add, err := mail.ParseAddressList(hdr) + if err != nil { + return []*mail.Address{{Name: hdr}}, nil + } + return add, err } // RawMessage is an interface that describes a raw message |