From 6c3098a134d262c8919417fd8b7ddadb6a1c8a2d Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 28 Dec 2020 14:51:48 +1000 Subject: [PATCH] converts encoding to lowercase I'm receiving emails from third parties which are incorrectly setting "Content-Transfer-Encoding" to "Base64" rather than "base64" --- parsemail.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsemail.go b/parsemail.go index 6a60192..e3054a7 100644 --- a/parsemail.go +++ b/parsemail.go @@ -345,7 +345,7 @@ func decodeAttachment(part *multipart.Part) (at Attachment, err error) { } func decodeContent(content io.Reader, encoding string) (io.Reader, error) { - switch encoding { + switch strings.ToLower(encoding) { case "base64": decoded := base64.NewDecoder(base64.StdEncoding, content) b, err := ioutil.ReadAll(decoded) @@ -490,4 +490,4 @@ type Email struct { Attachments []Attachment EmbeddedFiles []EmbeddedFile -} \ No newline at end of file +}