From da6eac3a6a25a040473fcdc318c1154b713db773 Mon Sep 17 00:00:00 2001 From: mscdex Date: Sun, 13 Jan 2013 14:34:38 -0500 Subject: [PATCH] don't include ".PEEK" in fetch keys, only in command where applicable --- lib/imap.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/imap.js b/lib/imap.js index eddcebe..63b8eaa 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -925,7 +925,7 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { uids = [uids]; utils.validateUIDList(uids); - var toFetch = '', prefix, extensions, self = this, + var toFetch = '', prefix = ' BODY[', extensions, self = this, parse = true, headers, key, stream, fetchers = {}; @@ -934,9 +934,9 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { what = options; options = {}; } - prefix = (options.markSeen ? ' BODY.PEEK[' : ' BODY['); if (!Array.isArray(what)) what = [what]; + for (var i = 0, wp, pprefix, len = what.length; i < len; ++i) { wp = what[i]; if (wp.id !== undefined && !/^(?:[\d]+[\.]{0,1})*[\d]+$/.test(''+wp.id)) @@ -1117,8 +1117,12 @@ ImapConnection.prototype._fetch = function(which, uids, options, what, cb) { cmd += ' BODYSTRUCTURE'; if (options.size) cmd += ' RFC822.SIZE'; - if (toFetch) - cmd += toFetch; + if (toFetch) { + if (!options.markSeen) + cmd += toFetch.replace(/BODY\[/g, 'BODY.PEEK['); + else + cmd += toFetch; + } cmd += ')'; this._send(cmd, function(err) {