diff options
author | Reto Brunner <reto@labrat.space> | 2020-11-10 20:35:47 +0100 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-11-14 15:40:13 +0100 |
commit | 24f1c575ae7941fa4239ec60bd86aef2f6641364 (patch) | |
tree | aaf355b590014fa4a6eb0a1ed16edbe9322948bd /lib | |
parent | 20ec2c8eeb2e071f28358814935a0f56672a9f49 (diff) | |
download | aerc-24f1c575ae7941fa4239ec60bd86aef2f6641364.tar.gz |
format: remove parse methods, use the one from go-message
Diffstat (limited to 'lib')
-rw-r--r-- | lib/format/format.go | 33 |
1 files changed, 1 insertions, 32 deletions
diff --git a/lib/format/format.go b/lib/format/format.go index 2ba4d64..30e8be7 100644 --- a/lib/format/format.go +++ b/lib/format/format.go @@ -3,46 +3,15 @@ package format import ( "errors" "fmt" - "mime" - gomail "net/mail" "regexp" "strings" "time" "unicode" "git.sr.ht/~sircmpwn/aerc/models" - "github.com/emersion/go-message" "github.com/emersion/go-message/mail" ) -func ParseAddress(address string) (*mail.Address, error) { - addrs, err := gomail.ParseAddress(address) - if err != nil { - return nil, err - } - return (*mail.Address)(addrs), nil -} - -func ParseAddressList(s string) ([]*mail.Address, error) { - if len(s) == 0 { - // we don't consider an empty list to be an error - return nil, nil - } - parser := gomail.AddressParser{ - &mime.WordDecoder{message.CharsetReader}, - } - list, err := parser.ParseList(s) - if err != nil { - return nil, err - } - - addrs := make([]*mail.Address, len(list)) - for i, a := range list { - addrs[i] = (*mail.Address)(a) - } - return addrs, nil -} - // AddressForHumans formats the address. If the address's name // contains non-ASCII characters it will be quoted but not encoded. // Meant for display purposes to the humans, not for sending over the wire. @@ -83,7 +52,7 @@ func ParseMessageFormat(format string, timeFmt string, ctx Ctx) (string, retval := make([]byte, 0, len(format)) var args []interface{} - accountFromAddress, err := ParseAddress(ctx.FromAddress) + accountFromAddress, err := mail.ParseAddress(ctx.FromAddress) if err != nil { return "", nil, err } |