Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/operations/MIMEDecoding.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
33 changes: 33 additions & 0 deletions tests/operations/tests/MIMEDecoding.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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?= <moore@cs.utk.edu>\nTo: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>\nCC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>\nSubject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=\n=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=",
Expand Down