From 5fa85344dd5d3edaa745f84d636ae10822cb27cf Mon Sep 17 00:00:00 2001 From: Devchanki Date: Tue, 7 May 2024 20:35:17 +0900 Subject: [PATCH 1/3] Ignore finishing dot message parts. multiline response finished \r\n.\r\n change test messages --- __mocks__/tls.js | 3 +-- lib/yapople.js | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__mocks__/tls.js b/__mocks__/tls.js index b118135..5b8f7b9 100644 --- a/__mocks__/tls.js +++ b/__mocks__/tls.js @@ -45,8 +45,7 @@ CjxIVE1MPjxCT0RZPjxkaXY+MTIzPC9kaXY+PGRpdj4xMjM8L2Rpdj48ZGl2IGRhdGEtc2lnbmF0 dXJlLXdpZGdldD0iY29udGFpbmVyIj48ZGl2IGRhdGEtc2lnbmF0dXJlLXdpZGdldD0iY29udGVu dCI+PGRpdj4tLTxicj5ZYXBvcGxlIFlhcG9wbGU8L2Rpdj48L2Rpdj48L2Rpdj48L0JPRFk+PC9I VE1MPgo= -----ALT--e2F8f5F19Ae0d3Ad5402B90c94Da42261610599299-- -.` + '\r\n'; +----ALT--e2F8f5F19Ae0d3Ad5402B90c94Da42261610599299--`+ '\r\n.\r\n'; let messages = Array.from(new Array(4)).fill(msg); diff --git a/lib/yapople.js b/lib/yapople.js index bcba26f..11ce2cb 100644 --- a/lib/yapople.js +++ b/lib/yapople.js @@ -158,6 +158,7 @@ function onData(data) { if (typeof this.flow !== 'undefined') { // for first and all next data chunks this.flow = Buffer.concat([this.flow, data]); // append chunk to buffer + if (this._command.cmd === state.RETR && sData.slice(-5) !== '\r\n.\r\n') return; if ( this.flow.slice(this.flow.length - 3).toString() === '.\r\n' || sData.substr(-3) === '.\r\n' From 5ed2d738326920afb5e58baf9a834928a7c04ac1 Mon Sep 17 00:00:00 2001 From: Devchanki Date: Wed, 8 May 2024 23:02:03 +0900 Subject: [PATCH 2/3] change bugs and versions --- lib/yapople.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/yapople.js b/lib/yapople.js index 11ce2cb..f5d648e 100644 --- a/lib/yapople.js +++ b/lib/yapople.js @@ -158,7 +158,7 @@ function onData(data) { if (typeof this.flow !== 'undefined') { // for first and all next data chunks this.flow = Buffer.concat([this.flow, data]); // append chunk to buffer - if (this._command.cmd === state.RETR && sData.slice(-5) !== '\r\n.\r\n') return; + if (this._command.cmd === state.RETR && this.flow.slice(-5).toString() !== '\r\n.\r\n') return; if ( this.flow.slice(this.flow.length - 3).toString() === '.\r\n' || sData.substr(-3) === '.\r\n' diff --git a/package.json b/package.json index 64d7941..016f899 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yapople", - "version": "0.4.8", + "version": "0.4.9", "author": "Andrew D.Laptev ", "description": "Yet another POP3 library", "main": "lib/yapople.js", From f174933fa25a3ae62793fa0ba65e2e8e40b9c42e Mon Sep 17 00:00:00 2001 From: Devchanki Date: Thu, 16 May 2024 21:23:15 +0900 Subject: [PATCH 3/3] Cleaning repetitive logic --- lib/yapople.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/yapople.js b/lib/yapople.js index f5d648e..4b0831b 100644 --- a/lib/yapople.js +++ b/lib/yapople.js @@ -158,10 +158,8 @@ function onData(data) { if (typeof this.flow !== 'undefined') { // for first and all next data chunks this.flow = Buffer.concat([this.flow, data]); // append chunk to buffer - if (this._command.cmd === state.RETR && this.flow.slice(-5).toString() !== '\r\n.\r\n') return; if ( - this.flow.slice(this.flow.length - 3).toString() === '.\r\n' || - sData.substr(-3) === '.\r\n' + this.flow.slice(this.flow.length - 5).toString() === '\r\n.\r\n' || sData.substr(-5) === '\r\n.\r\n' ) { this.flow = this.flow.slice(0, this.flow.length - 5); if (this.mailparser) {