From 839225571839949a38740fc4cbf3257d1ea3ceaf Mon Sep 17 00:00:00 2001 From: Suraj Sharma Date: Mon, 8 Aug 2016 20:07:26 +0530 Subject: [PATCH] Added support for + symbol response in RE_PRECEDING regex. In case of IMAP IDLE some servers give time breakup in their response. Running RE_PRECEDING regex over it was falsely matching + symbol but at a wrong place (some where in the mid). It should be only matching at the first place. --- lib/Parser.js | 2 +- test/test-parser.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Parser.js b/lib/Parser.js index c00a1ac02..426c38337 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -11,7 +11,7 @@ var CH_LF = 10, LITPLACEHOLDER = String.fromCharCode(0), EMPTY_READCB = function(n) {}, RE_INTEGER = /^\d+$/, - RE_PRECEDING = /^(?:(?:\*|A\d+) )|\+ ?/, + RE_PRECEDING = /^(?:(?:\*|A\d+) )|^\+ ?/, RE_BODYLITERAL = /BODY\[(.*)\] \{(\d+)\}$/i, RE_BODYINLINEKEY = /^BODY\[(.*)\]$/i, RE_SEQNO = /^\* (\d+)/, diff --git a/test/test-parser.js b/test/test-parser.js index f43857134..3ac592f12 100644 --- a/test/test-parser.js +++ b/test/test-parser.js @@ -20,6 +20,10 @@ var CR = '\r', LF = '\n', CRLF = CR + LF; expected: [ 'IDLE OK IDLE terminated' ], what: 'Unknown line' }, + { source: ['IDLE OK Idle completed (0.001 + 0.081 + 0.081 secs).', CRLF], + expected: [ 'IDLE OK Idle completed (0.001 + 0.081 + 0.081 secs).' ], + what: 'Unknown line with + char' + }, { source: ['+ idling', CRLF], expected: [ { textCode: undefined, text: 'idling'