Preserve QOutlook inline EML attachments
This commit is contained in:
@@ -200,6 +200,7 @@ export function extractMessageBody(headers: MailHeaders, body: string): string {
|
||||
|
||||
const bodyParts = parseMultipartBody(body, boundary)
|
||||
.filter((part) => !isAttachmentPart(part.headers))
|
||||
.filter((part) => isMessageBodyPart(part.headers))
|
||||
.map((part) => {
|
||||
const partType = parseContentType(part.headers["content-type"]);
|
||||
return {
|
||||
@@ -718,13 +719,20 @@ function unquoteHeaderValue(value: string): string {
|
||||
function isAttachmentPart(headers: MailHeaders): boolean {
|
||||
const disposition = parseContentDisposition(headers["content-disposition"]);
|
||||
const contentType = parseContentType(headers["content-type"]);
|
||||
const dispositionValue = disposition.value.toLowerCase();
|
||||
return (
|
||||
disposition.value.toLowerCase() === "attachment" ||
|
||||
dispositionValue === "attachment" ||
|
||||
(dispositionValue === "inline" && Boolean(headers["content-id"])) ||
|
||||
Boolean(decodeMimeParameter(disposition.parameters, "filename")) ||
|
||||
Boolean(decodeMimeParameter(contentType.parameters, "name"))
|
||||
);
|
||||
}
|
||||
|
||||
function isMessageBodyPart(headers: MailHeaders): boolean {
|
||||
const contentType = parseContentType(headers["content-type"]);
|
||||
return contentType.mediaType.startsWith("multipart/") || contentType.mediaType === "text/plain" || contentType.mediaType === "text/html";
|
||||
}
|
||||
|
||||
function decodeHtmlEntities(value: string): string {
|
||||
const namedEntities: Record<string, string> = {
|
||||
amp: "&",
|
||||
|
||||
Reference in New Issue
Block a user