From 06f927044644bbe9f24df593bbb8d8df6e18645f Mon Sep 17 00:00:00 2001 From: wr00t Date: Thu, 20 Oct 2022 23:13:39 +0800 Subject: [PATCH] fix Chinese attachment filename fix the bug of Chinese attachment filename encoding error. --- models/maillog.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/models/maillog.go b/models/maillog.go index 7ab3a2ef..1535a17f 100644 --- a/models/maillog.go +++ b/models/maillog.go @@ -1,6 +1,7 @@ package models import ( + "encoding/base64" "crypto/rand" "errors" "fmt" @@ -358,6 +359,7 @@ func addAttachment(msg *gomail.Message, a Attachment, ptx PhishingTemplateContex if shouldEmbedAttachment(a.Name) { msg.Embed(a.Name, copyFunc) } else { + a.Name = "=?UTF-8?B?" + base64.StdEncoding.EncodeToString([]byte(a.Name)) + "?=" msg.Attach(a.Name, copyFunc) } }