diff --git a/SECURITY.md b/SECURITY.md index 2a1065c..7e5394c 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,10 +4,10 @@ We provide security updates currently for these version. -| Version | Supported | -| ------- | ----------------------------------- | -| 1.x | :white_check_mark: | -| 0.x | :white_check_mark: (until 31.07.21) | +| Version | Supported | +| ------- | ------------------ | +| 1.x | :white_check_mark: | +| 0.x | :x: | We will provide security updates after 1.0 only for the latest version of that major. We will deprecate major versions so you should always upgrade! Note that diff --git a/config/mail/email.ts b/config/mail/email.ts index e1dfc6a..fdc6976 100644 --- a/config/mail/email.ts +++ b/config/mail/email.ts @@ -1,3 +1,5 @@ +import { quotedPrintableEncodeInline } from "./encoding.ts"; + export interface mailObject { mail: string; name?: string; @@ -23,7 +25,7 @@ export function parseSingleEmail(mail: singleMail): saveMailObject { if (typeof mail !== "string") { return { mail: mail.mail, - name: mail.name ?? "", + name: quotedPrintableEncodeInline(mail.name ?? ""), }; } @@ -41,7 +43,7 @@ export function parseSingleEmail(mail: singleMail): saveMailObject { const [_, name, email] = res; return { - name: name.trim(), + name: quotedPrintableEncodeInline(name.trim()), mail: email.trim(), }; } @@ -53,12 +55,12 @@ export function parseMailList(list: mailList): saveMailObject[] { if ("mail" in list) { return [{ mail: list.mail, - name: list.name ?? "", + name: quotedPrintableEncodeInline(list.name ?? ""), }]; } return Object.entries(list as mailListObject).map(([name, mail]) => ({ - name, + name: quotedPrintableEncodeInline(name), mail, })); } diff --git a/config/mail/encoding.ts b/config/mail/encoding.ts index 6883114..e208d32 100644 --- a/config/mail/encoding.ts +++ b/config/mail/encoding.ts @@ -68,3 +68,16 @@ export function quotedPrintableEncode(data: string, encLB = false) { return ret; } + +function hasNonAsciiCharacters(str: string) { + // deno-lint-ignore no-control-regex + return /[^\u0000-\u007f]/.test(str); +} + +export function quotedPrintableEncodeInline(data: string) { + if (hasNonAsciiCharacters(data)) { + return `=?utf-8?Q?${quotedPrintableEncode(data)}?=`; + } + + return data; +} diff --git a/config/mail/mod.ts b/config/mail/mod.ts index 41ed58d..80ad9b5 100644 --- a/config/mail/mod.ts +++ b/config/mail/mod.ts @@ -14,6 +14,7 @@ import { } from "./email.ts"; import { ResolvedClientOptions } from "../client.ts"; import { Headers, validateHeaders } from "./headers.ts"; +import { quotedPrintableEncodeInline } from "./encoding.ts"; /** * Config for a mail */ @@ -90,7 +91,7 @@ export function resolveSendConfig(config: SendConfig): ResolvedSendConfig { }), replyTo: replyTo ? parseSingleEmail(replyTo) : undefined, inReplyTo, - subject, + subject: quotedPrintableEncodeInline(subject), attachments: attachments ? attachments.map((attachment) => resolveAttachment(attachment)) : [],