From 61ffc105fd8480b0af4151e3fadb0751d38bea82 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 9 Dec 2019 13:45:15 +0100 Subject: Use imap.BodyStructure.Filename and imap.Address.Address The former fixes encoding issues in filenames. The latter is just for brevity. --- go.mod | 2 +- go.sum | 2 ++ handlers.go | 2 +- imap.go | 5 +---- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 1301e14..6107fbe 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.sr.ht/~emersion/koushin go 1.13 require ( - github.com/emersion/go-imap v1.0.1 + github.com/emersion/go-imap v1.0.3-0.20191208103636-6388a8c8bfdb github.com/emersion/go-message v0.10.8 github.com/emersion/go-sasl v0.0.0-20190817083125-240c8404624e github.com/emersion/go-smtp v0.12.0 diff --git a/go.sum b/go.sum index 9a2c1a0..46cc5b5 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumC github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/emersion/go-imap v1.0.1 h1:J3duplefIrglQtE63hCGYdGLgMjYWqHvkUUEbimbXY8= github.com/emersion/go-imap v1.0.1/go.mod h1:MEiDDwwQFcZ+L45Pa68jNGv0qU9kbW+SJzwDpvSfX1s= +github.com/emersion/go-imap v1.0.3-0.20191208103636-6388a8c8bfdb h1:WSeLbrNhAgjH21BVHUqtfhwX4Rnr31rvMi0Us6m5iWg= +github.com/emersion/go-imap v1.0.3-0.20191208103636-6388a8c8bfdb/go.mod h1:TjT+1ncDso8j/VXeUHcZeQknho5hjyQLqEIybJJjjDI= github.com/emersion/go-message v0.10.4-0.20190609165112-592ace5bc1ca h1:OYhqtJI4eOLvGtRIsUfP87VMJ1J/o6ks1tah9DlYkn4= github.com/emersion/go-message v0.10.4-0.20190609165112-592ace5bc1ca/go.mod h1:3h+HsGTCFHmk4ngJ2IV/YPhdlaOcR6hcgqM3yca9v7c= github.com/emersion/go-message v0.10.8 h1:1l1Vb+0By9U1ITTH3FgKfJQWQ9sTI3N1smPe6SS3QXY= diff --git a/handlers.go b/handlers.go index 21873a7..4615aa4 100644 --- a/handlers.go +++ b/handlers.go @@ -229,7 +229,7 @@ func handleCompose(ectx echo.Context) error { if len(replyTo) > 0 { msg.To = make([]string, len(replyTo)) for i, to := range replyTo { - msg.To[i] = to.MailboxName + "@" + to.HostName + msg.To[i] = to.Address() } } msg.Subject = inReplyTo.Envelope.Subject diff --git a/imap.go b/imap.go index 9081689..0e0edc1 100644 --- a/imap.go +++ b/imap.go @@ -174,10 +174,7 @@ func imapPartTree(bs *imap.BodyStructure, path []int) *IMAPPartNode { path = []int{1} } - var filename string - if strings.EqualFold(bs.Disposition, "attachment") { - filename = bs.DispositionParams["filename"] - } + filename, _ := bs.Filename() node := &IMAPPartNode{ Path: path, -- cgit v1.2.3