@zone-eu/mailsplit 5.4.23 → 5.4.24

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/lib/headers.js +10 -4
  2. package/package.json +1 -1
package/lib/headers.js CHANGED
@@ -365,10 +365,16 @@ class Headers {
365
365
  return;
366
366
  }
367
367
 
368
- let rawLines = this.headers
369
- .toString('binary')
370
- .replace(/[\r\n]+$/, '')
371
- .split(/\r?\n/);
368
+ let raw = this.headers.toString('binary');
369
+
370
+ // Trailing line breaks go with an index scan. /[\r\n]+$/ retried a run of carriage
371
+ // returns from every position in it, quadratic on a header line made of them
372
+ let end = raw.length;
373
+ while (end > 0 && (raw.charCodeAt(end - 1) === 0x0a || raw.charCodeAt(end - 1) === 0x0d)) {
374
+ end--;
375
+ }
376
+
377
+ let rawLines = raw.slice(0, end).split(/\r?\n/);
372
378
 
373
379
  // Single forward pass. Splicing folded lines out of the source array in place was
374
380
  // quadratic on a header block with many continuation lines.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zone-eu/mailsplit",
3
- "version": "5.4.23",
3
+ "version": "5.4.24",
4
4
  "description": "Split email messages into an object stream",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",