cache part id check regexp and perform type check in object(s) passed to fetch()

fork
mscdex 11 years ago
parent b786c82eec
commit 1e020b47c1

@ -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)

Loading…
Cancel
Save