From 5cbef361a01fba336bfeb7b1177f6ccb9393d99c Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 27 Jun 2025 14:45:01 -0700 Subject: [PATCH 01/15] doc(CONTRIBUTORS): updated --- .release | 2 +- CONTRIBUTORS.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.release b/.release index 7307651..e5ca169 160000 --- a/.release +++ b/.release @@ -1 +1 @@ -Subproject commit 73076513e83c2057a32515831b638771c15b1d83 +Subproject commit e5ca16937e4a27d394544100e39e2d1fb532e77e diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c1bfa38..4e51ce2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,9 +1,9 @@ # Contributors -This handcrafted artisinal software is brought to you by: +This handcrafted artisanal software is brought to you by: -|
msimerson (6) | -| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | +|
msimerson (7)| +| :---: | this file is generated by [.release](https://github.com/msimerson/.release). Contribute to this project to get your GitHub profile included here. From 51859911bdf8df89fb4cb16651217dbd7fbf55ac Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 27 Jun 2025 14:46:42 -0700 Subject: [PATCH 02/15] change: rename dot_stuffing -> dot_stuffed, consistent with Haraka --- CHANGELOG.md | 8 ++++++++ README.md | 5 +++++ index.js | 10 ++++------ package.json | 6 +++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d89d8b8..a677ead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### Unreleased +### [1.3.0] - 2025-06-27 + +- change: rename dot_stuffing -> dot_stuffed, consistent with Haraka + - improves readability, fixes a case of the not nots +- doc(README): add ref to Haraka Transaction docs showing usage +- deps(test-fixtures: bump to latest + ### [1.2.3] - 2025-02-02 - dep(eslint): upgrade to v9 @@ -43,3 +50,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). [1.2.2]: https://github.com/haraka/message-stream/releases/tag/v1.2.2 [1.2.3]: https://github.com/haraka/message-stream/releases/tag/v1.2.3 [1.0.0]: https://github.com/haraka/message-stream/releases/tag/v1.0.0 +[1.3.0]: https://github.com/haraka/message-stream/releases/tag/v1.3.0 diff --git a/README.md b/README.md index d661c6f..366c589 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ new MessageStream(cfg, uuid, header_list) ``` +## REFERENCES + +Usage of this module is documented in the Haraka [Transaction](https://haraka.github.io/core/Transaction) docs. + + [ci-img]: https://github.com/haraka/message-stream/actions/workflows/ci.yml/badge.svg diff --git a/index.js b/index.js index 6937576..a7dd05a 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ class MessageStream extends Stream { this.headers_done = false this.headers_found_eoh = false this.line_endings = '\r\n' - this.dot_stuffing = false + this.dot_stuffed = true this.ending_dot = false this.buffer_size = 1024 * 64 this.start = 0 @@ -279,7 +279,7 @@ class MessageStream extends Stream { } // Remove dot-stuffing if required if ( - !this.dot_stuffing && + this.dot_stuffed && line.length >= 4 && line[0] === 0x2e && line[1] === 0x2e @@ -334,7 +334,7 @@ class MessageStream extends Stream { Stream.prototype.pipe.call(this, destination, options) // Options this.line_endings = options?.line_endings ?? '\r\n' - this.dot_stuffing = options?.dot_stuffing ?? false + this.dot_stuffed = options?.dot_stuffed ?? true this.ending_dot = options?.ending_dot ?? false this.clamd_style = !!options?.clamd_style this.buffer_size = options?.buffer_size ?? 1024 * 64 @@ -463,9 +463,7 @@ class ChunkEmitter extends EventEmitter { } fill(input) { - if (typeof input === 'string') { - input = Buffer.from(input) - } + if (typeof input === 'string') input = Buffer.from(input) // Optimization: don't allocate a new buffer until the input we've // had so far is bigger than our buffer size. diff --git a/package.json b/package.json index 16f2c55..baf5938 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haraka-message-stream", - "version": "1.2.3", + "version": "1.3.0", "description": "Haraka email message stream", "main": "index.js", "files": [ @@ -33,11 +33,11 @@ "homepage": "https://github.com/haraka/message-stream#readme", "devDependencies": { "@haraka/eslint-config": "^2.0.2", - "haraka-test-fixtures": "^1.3.9" + "haraka-test-fixtures": "^1.3.10" }, "dependencies": {}, "prettier": { "singleQuote": true, "semi": false } -} +} \ No newline at end of file From 75ab1fb62cf8c84b3b440b99ef8cfd5ae90137a9 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 27 Jun 2025 14:47:01 -0700 Subject: [PATCH 03/15] chore: format --- CONTRIBUTORS.md | 4 ++-- README.md | 1 - package.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4e51ce2..2212ac0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,8 +2,8 @@ This handcrafted artisanal software is brought to you by: -|
msimerson (7)| -| :---: | +|
msimerson (7) | +| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | this file is generated by [.release](https://github.com/msimerson/.release). Contribute to this project to get your GitHub profile included here. diff --git a/README.md b/README.md index 366c589..6d82975 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ new MessageStream(cfg, uuid, header_list) Usage of this module is documented in the Haraka [Transaction](https://haraka.github.io/core/Transaction) docs. - [ci-img]: https://github.com/haraka/message-stream/actions/workflows/ci.yml/badge.svg diff --git a/package.json b/package.json index baf5938..85c748b 100644 --- a/package.json +++ b/package.json @@ -40,4 +40,4 @@ "singleQuote": true, "semi": false } -} \ No newline at end of file +} From 6c4f6531fe1e1226494cca0b86ad5ba7102a2e90 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 1 Jul 2025 08:22:40 -0700 Subject: [PATCH 04/15] fix: also un-dot-stuff leftovers fix for haraka/haraka-plugin-dkim#17 --- index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index a7dd05a..550560b 100644 --- a/index.js +++ b/index.js @@ -261,6 +261,14 @@ class MessageStream extends Stream { } } + remove_dot_stuffing(buf) { + if (!this.dot_stuffed) return + + if (buf.length >= 4 && buf[0] === 0x2E && buf[1] === 0x2E) { + buf = buf.slice(1) + } + } + process_buf(buf) { let offset = 0 while ((offset = indexOfLF(buf)) !== -1) { @@ -277,15 +285,10 @@ class MessageStream extends Stream { } continue } + // Remove dot-stuffing if required - if ( - this.dot_stuffed && - line.length >= 4 && - line[0] === 0x2e && - line[1] === 0x2e - ) { - line = line.slice(1) - } + this.remove_dot_stuffing(line) + // We store lines in native CRLF format; so strip CR if requested if ( this.line_endings === '\n' && @@ -302,6 +305,7 @@ class MessageStream extends Stream { } // Check for data left in the buffer if (buf.length > 0 && this.headers_found_eoh) { + this.remove_dot_stuffing(buf) this.read_ce.fill(buf) } } From 6415ce5bec22a4704ee94602c630d1257169871b Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 1 Jul 2025 08:25:55 -0700 Subject: [PATCH 05/15] update changes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a677ead..22403ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### [1.3.0] - 2025-06-27 +- fix: also remove dot-stuffing from leftovers #9 - change: rename dot_stuffing -> dot_stuffed, consistent with Haraka - improves readability, fixes a case of the not nots - doc(README): add ref to Haraka Transaction docs showing usage From 227eccaa86e5efe0c124da60443811ae1d5918af Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 1 Jul 2025 08:27:56 -0700 Subject: [PATCH 06/15] doc: improve comments --- index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.js b/index.js index 550560b..6527001 100644 --- a/index.js +++ b/index.js @@ -286,10 +286,9 @@ class MessageStream extends Stream { continue } - // Remove dot-stuffing if required this.remove_dot_stuffing(line) - // We store lines in native CRLF format; so strip CR if requested + // lines are stored in native CRLF format; strip CR if requested if ( this.line_endings === '\n' && line.length >= 2 && From 794870964fadef3cac9affd94b293e857558bddc Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 1 Jul 2025 08:34:56 -0700 Subject: [PATCH 07/15] fix: replace polynomial regex with trimEnd() --- CHANGELOG.md | 1 + index.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22403ce..daa81f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### [1.3.0] - 2025-06-27 - fix: also remove dot-stuffing from leftovers #9 +- fix: replace polynomial regex with trimEnd() - change: rename dot_stuffing -> dot_stuffed, consistent with Haraka - improves readability, fixes a case of the not nots - doc(README): add ref to Haraka Transaction docs showing usage diff --git a/index.js b/index.js index 6527001..d0a8dad 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ class MessageStream extends Stream { if (this.state === STATE.BODY) { // Look for MIME boundaries if (line.length > 4 && line[0] === 0x2d && line[1] == 0x2d) { - let boundary = line.slice(2).toString().replace(/\s*$/, '') + let boundary = line.slice(2).toString().trimEnd() if (/--\s*$/.test(line)) { // End of boundary? boundary = boundary.slice(0, -2) From 24c564c02d3bbdf7001c747d4a3018df42a6831b Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 1 Jul 2025 09:46:35 -0700 Subject: [PATCH 08/15] switch test runner from mocha -> node --test --- CHANGELOG.md | 1 + eslint.config.mjs | 8 ++++- index.js | 4 +-- package.json | 4 +-- test/chunk-emitter.js | 72 +++++++++++++++++++----------------------- test/message-stream.js | 35 ++++++++++---------- 6 files changed, 61 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daa81f9..c919178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - fix: replace polynomial regex with trimEnd() - change: rename dot_stuffing -> dot_stuffed, consistent with Haraka - improves readability, fixes a case of the not nots +- change: switch test runner from mocha -> node --test - doc(README): add ref to Haraka Transaction docs showing usage - deps(test-fixtures: bump to latest diff --git a/eslint.config.mjs b/eslint.config.mjs index 0377960..41dd6b0 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,7 +23,13 @@ export default [ }, rules: { - 'no-unused-vars': ['warn'], + 'no-unused-vars': [ + 'warn', + { + args: 'none', + caughtErrorsIgnorePattern: 'ignore', + }, + ], }, }, ] diff --git a/index.js b/index.js index d0a8dad..59d7f0c 100644 --- a/index.js +++ b/index.js @@ -264,7 +264,7 @@ class MessageStream extends Stream { remove_dot_stuffing(buf) { if (!this.dot_stuffed) return - if (buf.length >= 4 && buf[0] === 0x2E && buf[1] === 0x2E) { + if (buf.length >= 4 && buf[0] === 0x2e && buf[1] === 0x2e) { buf = buf.slice(1) } } @@ -403,7 +403,7 @@ class MessageStream extends Stream { } else { fs.unlink(this.filename, () => {}) } - } catch (err) { + } catch (ignore) { // Ignore any errors } } diff --git a/package.json b/package.json index 85c748b..59f1913 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "lint:fix": "npx eslint@^9 --fix *.js test", "prettier": "npx prettier . --check", "prettier:fix": "npx prettier . --write --log-level=warn", - "test": "npx mocha@^11", + "test": "node --test", "versions": "npx dependency-version-checker check", "versions:fix": "npx dependency-version-checker update && npm run prettier:fix" }, @@ -32,7 +32,7 @@ }, "homepage": "https://github.com/haraka/message-stream#readme", "devDependencies": { - "@haraka/eslint-config": "^2.0.2", + "@haraka/eslint-config": "^2.0.3", "haraka-test-fixtures": "^1.3.10" }, "dependencies": {}, diff --git a/test/chunk-emitter.js b/test/chunk-emitter.js index 705e728..9e3d8fd 100644 --- a/test/chunk-emitter.js +++ b/test/chunk-emitter.js @@ -1,66 +1,60 @@ const assert = require('assert') +const { describe, it } = require('node:test') const fs = require('fs') const path = require('path') const ChunkEmitter = require('../index').ChunkEmitter describe('chunk-emitter', function () { - beforeEach(function () { - this.ce = new ChunkEmitter() - this._written = 0 - }) - - it('loads', function () { - assert.ok(this.ce) - }) - - it('emits all unbuffered bytes', function (done) { + it('emits all unbuffered bytes', async () => { const msgPath = path.join(__dirname, 'fixtures', 'haraka-icon-attach.eml') const eml = fs.readFileSync(msgPath, 'utf8') - this._write = (data) => { - this._written = (this._written || 0) + data.length - if (eml.length === this._written) { - assert.equal(eml.length, this._written) - done() - } - } + let written = 0 - this.ce.on('data', (chunk) => { - this._write(chunk) + const ce = new ChunkEmitter() + + const dataPromise = new Promise((resolve) => { + ce.on('data', (chunk) => { + written += chunk.length + if (written === eml.length) { + resolve(written) + } + }) }) - this.ce.fill(eml) - this.ce.end() + ce.fill(eml) + ce.end() + + const total = await dataPromise + assert.equal(total, eml.length) }) - it('emits all bigger than buffer bytes', function (done) { + it('emits all bigger than buffer bytes', async () => { const msgPath = path.join( __dirname, 'fixtures', 'haraka-tarball-attach.eml', ) - // console.log(`msgPath: ${msgPath}`) const eml = fs.readFileSync(msgPath, 'utf8') - // console.log(`length: ${eml.length}`) - this._write = (data) => { - // console.log(`_write: ${data.length} bytes`) - this._written = this._written + data.length - // console.log(`_written: ${this._written}`) - if (eml.length === this._written) { - assert.equal(eml.length, this._written) - // console.log(this.ce) - done() - } - } + let written = 0 - this.ce.on('data', (chunk) => { - // console.log(`ce.on.data: ${chunk.length} bytes`) - this._write(chunk) + const ce = new ChunkEmitter() + + const dataPromise = new Promise((resolve) => { + ce.on('data', (chunk) => { + written += chunk.length + if (written === eml.length) { + resolve(written) + } + }) }) - this.ce.fill(eml) - this.ce.end() + ce.fill(eml) + ce.end() + + const total = await dataPromise + assert.equal(total, eml.length) }) }) diff --git a/test/message-stream.js b/test/message-stream.js index de11d14..a47447d 100644 --- a/test/message-stream.js +++ b/test/message-stream.js @@ -1,29 +1,26 @@ const assert = require('assert') +const { describe, it } = require('node:test') const stream = require('stream') const MessageStream = require('../index') -function _set_up() { - this.ms = new MessageStream({ main: {} }, 'msg', []) -} - -describe('message-stream', function () { - beforeEach(_set_up) - - it('is a Stream', function (done) { - assert.ok(this.ms instanceof MessageStream) - assert.ok(this.ms instanceof stream.Stream) - done() +describe('message-stream', () => { + it('is a Stream', () => { + const ms = new MessageStream({ main: {} }, 'msg', []) + assert.ok(ms instanceof MessageStream) + assert.ok(ms instanceof stream.Stream) }) - it('gets message data', function (done) { - this.ms.add_line('Header: test\r\n') - this.ms.add_line('\r\n') - this.ms.add_line('I am body text\r\n') - this.ms.add_line_end() - this.ms.get_data((data) => { - assert.ok(/^[A-Za-z]+: /.test(data.toString())) - done() + it('gets message data', async () => { + const ms = new MessageStream({ main: {} }, 'msg', []) + ms.add_line('Header: test\r\n') + ms.add_line('\r\n') + ms.add_line('I am body text\r\n') + ms.add_line_end() + + const data = await new Promise((resolve) => { + ms.get_data((data) => resolve(data)) }) + assert.ok(/^[A-Za-z]+: /.test(data.toString())) }) }) From 30a9f0f65f26540607bbc0bae930a35ecec4cc00 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Tue, 1 Jul 2025 09:51:51 -0700 Subject: [PATCH 09/15] doc: add credit for sleuthing --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c919178..d9c1178 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ### [1.3.0] - 2025-06-27 - fix: also remove dot-stuffing from leftovers #9 + - thanks to report at haraka/haraka-plugin-dkim#17 - fix: replace polynomial regex with trimEnd() - change: rename dot_stuffing -> dot_stuffed, consistent with Haraka - improves readability, fixes a case of the not nots From ffbed560dfa0a97c1a09db573576d06d1d0862dc Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Jul 2025 09:21:39 -0700 Subject: [PATCH 10/15] dot stuffing: primitives are passed by value --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 59d7f0c..3fdf0e5 100644 --- a/index.js +++ b/index.js @@ -265,8 +265,9 @@ class MessageStream extends Stream { if (!this.dot_stuffed) return if (buf.length >= 4 && buf[0] === 0x2e && buf[1] === 0x2e) { - buf = buf.slice(1) + return buf.slice(1) } + return buf } process_buf(buf) { @@ -286,7 +287,7 @@ class MessageStream extends Stream { continue } - this.remove_dot_stuffing(line) + line = this.remove_dot_stuffing(line) // lines are stored in native CRLF format; strip CR if requested if ( @@ -304,8 +305,7 @@ class MessageStream extends Stream { } // Check for data left in the buffer if (buf.length > 0 && this.headers_found_eoh) { - this.remove_dot_stuffing(buf) - this.read_ce.fill(buf) + this.read_ce.fill(this.remove_dot_stuffing(buf)) } } From 9b143f773537e58c5616c866225aa8d5d55155a8 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Jul 2025 09:44:18 -0700 Subject: [PATCH 11/15] dot stuffing: add tests --- test/message-stream.js | 43 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/message-stream.js b/test/message-stream.js index a47447d..d53e493 100644 --- a/test/message-stream.js +++ b/test/message-stream.js @@ -1,4 +1,4 @@ -const assert = require('assert') +const assert = require('assert/strict') const { describe, it } = require('node:test') const stream = require('stream') @@ -24,3 +24,44 @@ describe('message-stream', () => { assert.ok(/^[A-Za-z]+: /.test(data.toString())) }) }) + +function getOutputFromStream(inputLines) { + return new Promise((resolve) => { + const ms = new MessageStream({ main: {} }, 'msg', []) + const output = new stream.PassThrough() + const chunks = [] + + output.on('data', chunk => chunks.push(chunk.toString())) + output.on('end', () => resolve(chunks.join(''))) + + ms.pipe(output) + inputLines.forEach(line => ms.add_line(line)) + ms.add_line_end() + }) +} + +describe('dot-unstuffing', function () { + + it('unstuffs "..\\r\\n" to ".\\r\\n"', async () => { + const result = await getOutputFromStream(['..\r\n']) + assert.match(result, /^.\r\n/m) + }) + + it('unstuffs "..dot start\\r\\n" to ".dot start\\r\\n"', async () => { + const result = await getOutputFromStream(['..dot start\r\n']) + assert.match(result, /^.dot start\r\n/m) + }) + + it('leaves normal lines untouched', async () => { + const result = await getOutputFromStream([ + 'hello\r\n', + '..dot line\r\n', + '..\r\n', + ]) + + assert.equal(result, 'hello\r\n.dot line\r\n.\r\n') + assert.match(result, /^hello\r\n/m) + assert.match(result, /^.dot line\r\n/m) + assert.match(result, /^.\r\n/m) + }) +}) From 5a0af32ad7eec510a33d853ba5cd257f7cb1957b Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Jul 2025 09:48:30 -0700 Subject: [PATCH 12/15] update changes --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9c1178..162469b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - fix: also remove dot-stuffing from leftovers #9 - thanks to report at haraka/haraka-plugin-dkim#17 +- test: add tests for removing dot-stuffing - fix: replace polynomial regex with trimEnd() - change: rename dot_stuffing -> dot_stuffed, consistent with Haraka - improves readability, fixes a case of the not nots -- change: switch test runner from mocha -> node --test +- change: switch test runner from mocha to `node --test` - doc(README): add ref to Haraka Transaction docs showing usage -- deps(test-fixtures: bump to latest +- deps(test-fixtures): bump to latest ### [1.2.3] - 2025-02-02 From ea3fbb25601bb97990186155516ef8b93bcf8a6b Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Jul 2025 09:56:31 -0700 Subject: [PATCH 13/15] test: add example pipe option --- index.js | 2 +- test/message-stream.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3fdf0e5..9fa02ad 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ class MessageStream extends Stream { this.headers_done = false this.headers_found_eoh = false this.line_endings = '\r\n' - this.dot_stuffed = true + this.dot_stuffed = cfg?.main.dot_stuffed ?? true this.ending_dot = false this.buffer_size = 1024 * 64 this.start = 0 diff --git a/test/message-stream.js b/test/message-stream.js index d53e493..1e83817 100644 --- a/test/message-stream.js +++ b/test/message-stream.js @@ -34,7 +34,8 @@ function getOutputFromStream(inputLines) { output.on('data', chunk => chunks.push(chunk.toString())) output.on('end', () => resolve(chunks.join(''))) - ms.pipe(output) + ms.pipe(output, { dot_stuffed: true }) + inputLines.forEach(line => ms.add_line(line)) ms.add_line_end() }) @@ -64,4 +65,6 @@ describe('dot-unstuffing', function () { assert.match(result, /^.dot line\r\n/m) assert.match(result, /^.\r\n/m) }) + + }) From 370a89fa6a8e25403ea91a7e45093d4f7bc27878 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 2 Jul 2025 10:19:11 -0700 Subject: [PATCH 14/15] empty catch --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 9fa02ad..478fc70 100644 --- a/index.js +++ b/index.js @@ -403,7 +403,7 @@ class MessageStream extends Stream { } else { fs.unlink(this.filename, () => {}) } - } catch (ignore) { + } catch { // Ignore any errors } } From 5325810e1a1e5e9680738e96f29cb0f0bd1bd2db Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Thu, 3 Jul 2025 14:36:41 -0700 Subject: [PATCH 15/15] update another return --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 478fc70..e84e78d 100644 --- a/index.js +++ b/index.js @@ -262,7 +262,7 @@ class MessageStream extends Stream { } remove_dot_stuffing(buf) { - if (!this.dot_stuffed) return + if (!this.dot_stuffed) return buf if (buf.length >= 4 && buf[0] === 0x2e && buf[1] === 0x2e) { return buf.slice(1)