diff --git a/lib/imap.js b/lib/imap.js index 8f842ab..3b236b2 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -28,6 +28,7 @@ var CRLF = '\r\n', RE_TEXT_CODE = /([^ ]+)(?: (.*))?$/, RE_RES_IDLE = /^IDLE /i, RE_RES_NOOP = /^NOOP /i, + RE_PARTID = /^(?:[\d]+[\.]{0,1})*[\d]+$/, //RE_ISPARTIAL = /<(\d+)>$/, RE_DBLQ = /"/g, RE_CMD = /^([^ ]+)(?: |$)/, @@ -1045,9 +1046,9 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { for (var i = 0, wp, pprefix, len = what.length; i < len; ++i) { wp = what[i]; parse = true; - if (wp.id !== undefined && !/^(?:[\d]+[\.]{0,1})*[\d]+$/.test(''+wp.id)) + if (wp.id !== undefined && !RE_PARTID.test(''+wp.id)) throw new Error('Invalid part id: ' + wp.id); - if (( (wp.headers + if (( (typeof wp.headers === 'object' && (!wp.headers.fields || (Array.isArray(wp.headers.fields) && wp.headers.fields.length === 0) @@ -1055,7 +1056,7 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { && wp.headers.parse === false ) || - (wp.headersNot + (typeof wp.headersNot === 'object' && (!wp.headersNot.fields || (Array.isArray(wp.headersNot.fields) && wp.headersNot.fields.length === 0)