diff --git a/src/core/operations/MIMEDecoding.mjs b/src/core/operations/MIMEDecoding.mjs index 7b52fbdd25..4ba04c1859 100644 --- a/src/core/operations/MIMEDecoding.mjs +++ b/src/core/operations/MIMEDecoding.mjs @@ -87,7 +87,7 @@ class MIMEDecoding extends Operation { end = cur + j + "?=".length; if (encoding.toLowerCase() === "b") { - text = fromBase64(text); + text = fromBase64(text, undefined, "byteArray"); } else if (encoding.toLowerCase() === "q") { text = this.parseQEncodedWord(text); } else { diff --git a/tests/operations/tests/MIMEDecoding.mjs b/tests/operations/tests/MIMEDecoding.mjs index b99fc489e1..2c3625422e 100644 --- a/tests/operations/tests/MIMEDecoding.mjs +++ b/tests/operations/tests/MIMEDecoding.mjs @@ -75,6 +75,39 @@ TestRegister.addTests([ } ] }, + { + name: "UTF-8 Base64 non-ASCII", + input: "Subject: =?UTF-8?B?Y2Fmw6k=?=", + expectedOutput: "Subject: café", + recipeConfig: [ + { + "op": "MIME Decoding", + "args": [] + } + ] + }, + { + name: "UTF-8 Base64 multibyte CJK", + input: "Subject: =?UTF-8?B?5pel5pys6Kqe?=", + expectedOutput: "Subject: 日本語", + recipeConfig: [ + { + "op": "MIME Decoding", + "args": [] + } + ] + }, + { + name: "UTF-8 Base64 ASCII-only", + input: "Subject: =?UTF-8?B?aGVsbG8=?=", + expectedOutput: "Subject: hello", + recipeConfig: [ + { + "op": "MIME Decoding", + "args": [] + } + ] + }, { name: "ISO Decoding", input: "From: =?US-ASCII?Q?Keith_Moore?= \nTo: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= \nCC: =?ISO-8859-1?Q?Andr=E9?= Pirard \nSubject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\n=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=",