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>
This commit is contained in:
parent
055c6dc660
commit
684ceed2cd
1 changed files with 9 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue