@bobfrankston/rmfmail 1.2.165 → 1.2.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10593,10 +10593,12 @@ var AndroidSyncManager = class {
10593
10593
  auth = { method: "XOAUTH2", user: smtpUser, token };
10594
10594
  }
10595
10595
  const parseAddrs = (s) => s.match(/[\w.+-]+@[\w.-]+/g) || [];
10596
- const toMatch = raw.match(/^To:\s*(.+)$/mi);
10597
- const ccMatch = raw.match(/^Cc:\s*(.+)$/mi);
10598
- const bccMatch = raw.match(/^Bcc:\s*(.+)$/mi);
10599
- const fromMatch = raw.match(/^From:\s*(.+)$/mi);
10596
+ const headerEnd = raw.search(/\r?\n\r?\n/);
10597
+ const headerSec = (headerEnd === -1 ? raw : raw.slice(0, headerEnd)).replace(/\r?\n[ \t]+/g, " ");
10598
+ const toMatch = headerSec.match(/^To:\s*(.+)$/mi);
10599
+ const ccMatch = headerSec.match(/^Cc:\s*(.+)$/mi);
10600
+ const bccMatch = headerSec.match(/^Bcc:\s*(.+)$/mi);
10601
+ const fromMatch = headerSec.match(/^From:\s*(.+)$/mi);
10600
10602
  const recipients = [
10601
10603
  ...toMatch ? parseAddrs(toMatch[1]) : [],
10602
10604
  ...ccMatch ? parseAddrs(ccMatch[1]) : [],
@@ -10604,7 +10606,8 @@ var AndroidSyncManager = class {
10604
10606
  ];
10605
10607
  const sender = fromMatch ? parseAddrs(fromMatch[1])[0] || account.email : account.email;
10606
10608
  if (recipients.length === 0) throw new Error("No recipients");
10607
- const rawToSend = raw.replace(/^Bcc:.*\r?\n/mi, "");
10609
+ const stripBcc = (h) => h.replace(/^Bcc:[^\n]*(\r?\n[ \t][^\n]*)*(\r?\n|$)/mi, "").replace(/\r?\n$/, "");
10610
+ const rawToSend = headerEnd === -1 ? stripBcc(raw) : stripBcc(raw.slice(0, headerEnd)) + raw.slice(headerEnd);
10608
10611
  const client = new SmtpClient({
10609
10612
  host: smtpHost,
10610
10613
  port: smtpPort,