Preserve QOutlook inline EML attachments

This commit is contained in:
Курнат Андрей
2026-06-01 08:25:11 +03:00
parent 472288badf
commit 1df1b1114e
3 changed files with 44 additions and 3 deletions
+33
View File
@@ -137,6 +137,39 @@ describe("outlookMail helpers", () => {
await expect(attachmentToBlob(attachments[0]).text()).resolves.toBe("Привет");
});
it("извлекает inline MIME-вложения с Content-ID и не добавляет бинарную часть в тело", async () => {
const body = [
"--related",
"Content-Type: text/html; charset=utf-8",
"",
"<p>Logo</p><img src=\"cid:logo\">",
"--related",
"Content-Type: image/png",
"Content-Disposition: inline",
"Content-ID: <logo>",
"Content-Transfer-Encoding: base64",
"",
"SGVsbG8=",
"--related--"
].join("\r\n");
const headers = { "content-type": 'multipart/related; boundary="related"' };
const attachments = extractMessageAttachments(headers, body);
expect(extractMessageBody(headers, body)).toBe("Logo");
expect(attachments).toEqual([
{
id: "attachment-вложение-1-1",
fileName: "Вложение 1",
contentType: "image/png",
size: 5,
contentBase64: "SGVsbG8=",
disposition: "inline",
contentId: "logo"
}
]);
await expect(attachmentToBlob(attachments[0]).text()).resolves.toBe("Hello");
});
it("импортирует multipart EML как письмо QOutlook", async () => {
const eml = [
"From: sender@example.com",