jordan-wright / email

Robust and flexible email library for Go
MIT License
2.61k stars 324 forks source link

Non-multipart emails are not decoded when CTE is Base64 #137

Closed leucos closed 3 years ago

leucos commented 3 years ago

When an email like the following gets decoded:

MIME-Version: 1.0
From: no-reply@example.com
To: tester@example.org
Date: 7 Jan 2021 03:07:44 -0800
Subject: Hello
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: base64
Message-Id: <20210107110744.547DD70532@example.com>

PGh0bWw+PGhlYWQ+PHRpdGxlPnRlc3Q8L3RpdGxlPjwvaGVhZD48Ym9keT5IZWxsbyB3
b3JsZCE8L2JvZHk+PC9odG1sPg==

content is not properly Base64 decoded and email.HTML is "UEdoMGJXdytQR2hsWVdRK1BIUnBkR3hsUG5SbGMzUThMM1JwZEd4bFBqd3ZhR1ZoWkQ0OFltOWtlVDVJWld4c2J5QjMNCmIzSnNaQ0U4TDJKdlpIaytQQzlvZEcxc1BnPT0NCg==" (base64 encoding of base64 of original HTML).

I guess the issue is located here: https://github.com/jordan-wright/email/blob/3f5bafa1cd84/email.go#L247

Here is a sample code snippet testing the above email: https://play.golang.org/p/CFDeclovcVo