@bobfrankston/rmfmail 1.2.227 → 1.2.228

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.
@@ -59,24 +59,34 @@ function capBodyForIpc(msg: any): any {
59
59
  if (!msg || typeof msg !== "object") return msg;
60
60
  const html = typeof msg.bodyHtml === "string" ? msg.bodyHtml : "";
61
61
  const text = typeof msg.bodyText === "string" ? msg.bodyText : "";
62
- const total = html.length + text.length;
63
- if (total <= IPC_BODY_MAX_BYTES) return msg;
64
62
 
65
- // Prefer the plain text when we have to truncate: a half-sent HTML
66
- // document renders as garbage (unclosed tags swallow the rest), whereas
67
- // half of a text body is simply the first half of the text.
68
- const keptText = text ? headOf(text, IPC_BODY_MAX_BYTES) : "";
69
- const keptHtml = !text && html ? "" : ""; // never ship partial HTML
70
- console.log(` [ipc] body too large for evaluate_script acct=${msg.accountId} uid=${msg.uid} `
71
- + `html=${html.length} text=${text.length} sending ${keptText.length} bytes of text + truncation notice`);
63
+ // A message with an HTML part is NEVER touched, at any size.
64
+ //
65
+ // The first cut of this guard truncated on total size and refused to send
66
+ // partial HTML, so a legitimate 9.8 MB message — one Bob had just written,
67
+ // large because of a pasted inline image arrived with its HTML dropped
68
+ // and rendered as "Showing the first 0.0 MB" (Bob 2026-08-08: "I pasted in
69
+ // an image and you blew it away?"). Destroying real content to protect the
70
+ // renderer is a worse failure than the one being protected against.
71
+ //
72
+ // What remains guarded is the genuinely pathological shape: NO MIME
73
+ // structure at all, so the entire multi-megabyte payload is one implicit
74
+ // text/plain part (a qmail bounce that inlines the whole original). There,
75
+ // the tail is base64 of a returned attachment — truncating it costs the
76
+ // user nothing, while the head carries every diagnostic that matters.
77
+ if (html) return msg;
78
+ if (text.length <= IPC_BODY_MAX_BYTES) return msg;
79
+
80
+ const keptText = headOf(text, IPC_BODY_MAX_BYTES);
81
+ console.log(` [ipc] MIME-less body of ${text.length} bytes — acct=${msg.accountId} uid=${msg.uid} `
82
+ + `→ sending first ${keptText.length} bytes with a truncation notice`);
72
83
  return {
73
84
  ...msg,
74
- bodyHtml: keptHtml,
75
85
  bodyText: keptText,
76
86
  bodyTruncated: {
77
- totalBytes: total,
87
+ totalBytes: text.length,
78
88
  sentBytes: keptText.length,
79
- hadHtml: html.length > 0,
89
+ hadHtml: false,
80
90
  emlPath: msg.emlPath || "",
81
91
  },
82
92
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-service",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",