From 685a6825720a5defbcf88a678548151268b25355 Mon Sep 17 00:00:00 2001 From: mscdex Date: Sun, 7 Apr 2013 20:44:05 -0400 Subject: [PATCH] more unsolicited response checks --- lib/imap.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/imap.js b/lib/imap.js index 0d334ec..738d9d3 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -309,9 +309,9 @@ ImapConnection.prototype.connect = function(loginCb) { } if (indata.line[0] === '*') { // Untagged server response - var isUnsolicited = - (requests[0] && requests[0].cmd === 'NOOP') - || (state.isIdle && state.ext.idle.state !== IDLE_NONE); + var isUnsolicited = (requests[0] && requests[0].cmd === 'NOOP') + || (state.isIdle && state.ext.idle.state !== IDLE_NONE) + || !requests.length; if (m = XRegExp.exec(indata.line, REX_UNRESPNUM)) { // m.type = response type (numeric-based) m.type = m.type.toUpperCase(); @@ -321,8 +321,13 @@ ImapConnection.prototype.connect = function(loginCb) { // m.info = message details var data, parsed, headers, f, lenf, body, lenb, msg, bodies, details, val; + + isUnsolicited = isUnsolicited + || (requests[0] && requests[0].cmd !== 'FETCH'); + if (!isUnsolicited) bodies = parsers.parseFetchBodies(m.info, indata.literals); + details = new ImapMessage(); parsers.parseFetch(m.info, indata.literals, details); details.seqno = parseInt(m.num, 10);