@bobfrankston/mailx-types 0.1.47 → 0.1.49

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.
Files changed (2) hide show
  1. package/mime-build.js +8 -1
  2. package/package.json +1 -1
package/mime-build.js CHANGED
@@ -146,8 +146,15 @@ function wrapWithAttachments(commonHeaders, inner, attachments, newBoundary) {
146
146
  return [...commonHeaders, ...inner.headers].join("\r\n") + `\r\n\r\n` + inner.body;
147
147
  }
148
148
  const mixedBoundary = newBoundary();
149
+ // RFC 2046: a boundary delimiter is "CRLF--boundary" — it MUST start its
150
+ // own line. The multipart/alternative inner body already ends with CRLF,
151
+ // but a bare quoted-printable body (draft, or a text-only send) does not,
152
+ // which glued `</p>--mailx_abc` together and made mailparser report ZERO
153
+ // attachments even though the bytes were all there. Normalize instead of
154
+ // assuming, so no future inner shape can reintroduce it.
155
+ const endCRLF = (s) => (s.endsWith("\r\n") ? s : s + "\r\n");
149
156
  const parts = [
150
- `--${mixedBoundary}\r\n` + inner.headers.join("\r\n") + `\r\n\r\n` + inner.body,
157
+ `--${mixedBoundary}\r\n` + inner.headers.join("\r\n") + `\r\n\r\n` + endCRLF(inner.body),
151
158
  ];
152
159
  for (const att of attachments) {
153
160
  // A quote or newline in a filename would break out of the header.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-types",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",