decodeMIMEHeader decodes any RFC 2047 encoded-word runs in a header value (e.g. `=?utf-8?Q?caf=C3=A9?=` → `café`). Used for display fields like Subject so downstream consumers (DB, list summaries, dashboard) see the UTF-8 form instead of the wire-encoded form. If decoding fails the original value is
(v string)
| 771 | // UTF-8 form instead of the wire-encoded form. If decoding fails the original |
| 772 | // value is returned — preserving the field is better than dropping it. |
| 773 | func decodeMIMEHeader(v string) string { |
| 774 | if v == "" { |
| 775 | return v |
| 776 | } |
| 777 | decoded, err := (&mime.WordDecoder{}).DecodeHeader(v) |
| 778 | if err != nil { |
| 779 | return v |
| 780 | } |
| 781 | return decoded |
| 782 | } |
| 783 | |
| 784 | // extractAddressList parses an RFC 5322 address-list header (To/Cc) into bare |
| 785 | // email addresses, dropping display names. Returns nil if the header is empty |