From 941b071f80f20e6b799ecfff065fcbeed1670672 Mon Sep 17 00:00:00 2001 From: Matthias Biggeleben Date: Fri, 16 Sep 2016 22:28:44 +0200 Subject: [PATCH] Parser: fix IDLE parsing Dovecot might answer DONE with some statistics: IDLE OK Idle completed (0.001 + 0.093 + 0.092 secs). The plus character passes RE_PRECEDING which leads to dead end code-wise. --- 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 c00a1ac..16297d3 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 f438571..39d1723 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.002 + 1.783 + 1.783 secs).', CRLF], + expected: [ 'IDLE OK Idle completed (0.002 + 1.783 + 1.783 secs).' ], + what: 'Unknown line with + char' + }, { source: ['+ idling', CRLF], expected: [ { textCode: undefined, text: 'idling'