mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 23:34:38 +03:00
fix parsing message headers with addresses that need double quotes
we are using Go's net/mail to parse message headers. it can parse addresses, and properly decodes email addresses with double quotes (e.g. " "@example.com). however, it gives us an address without the double quotes in the localpart, effectively an invalid address. we now have a workaround to parse such not-quite-addresses. for issue #199 reported by gene-hightower, thanks for reporting!
This commit is contained in:
@ -497,9 +497,9 @@ func parseAddressList(log mlog.Log, h mail.Header, k string) []Address {
|
||||
for _, a := range l {
|
||||
// todo: parse more fully according to ../rfc/5322:959
|
||||
var user, host string
|
||||
addr, err := smtp.ParseAddress(a.Address)
|
||||
addr, err := smtp.ParseNetMailAddress(a.Address)
|
||||
if err != nil {
|
||||
log.Infox("parsing address (continuing)", err, slog.Any("address", a.Address))
|
||||
log.Infox("parsing address (continuing)", err, slog.Any("netmailaddress", a.Address))
|
||||
} else {
|
||||
user = addr.Localpart.String()
|
||||
host = addr.Domain.ASCII
|
||||
|
Reference in New Issue
Block a user