|
|
|
@ -91,7 +91,7 @@ function ImapConnection (options) {
|
|
|
|
|
this.delimiter = undefined;
|
|
|
|
|
this.namespaces = { personal: [], other: [], shared: [] };
|
|
|
|
|
this.capabilities = [];
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inherits(ImapConnection, EventEmitter);
|
|
|
|
|
exports.ImapConnection = ImapConnection;
|
|
|
|
@ -462,14 +462,13 @@ ImapConnection.prototype.connect = function(loginCb) {
|
|
|
|
|
} else if (/^ALERT$/i.test(m[2]))
|
|
|
|
|
self.emit('alert', m[3]);
|
|
|
|
|
else if (state.status === STATES.BOXSELECTING) {
|
|
|
|
|
var r;
|
|
|
|
|
if (r = /^UIDVALIDITY (\d+)/i.exec(m[2]))
|
|
|
|
|
state.box.uidvalidity = r[1];
|
|
|
|
|
else if (r = /^UIDNEXT (\d+)/i.exec(m[2]))
|
|
|
|
|
state.box.uidnext = r[1];
|
|
|
|
|
else if (r = /^PERMANENTFLAGS \((.*)\)/i.exec(m[2])) {
|
|
|
|
|
if (m = /^UIDVALIDITY (\d+)/i.exec(m[2]))
|
|
|
|
|
state.box.uidvalidity = m[1];
|
|
|
|
|
else if (m = /^UIDNEXT (\d+)/i.exec(m[2]))
|
|
|
|
|
state.box.uidnext = m[1];
|
|
|
|
|
else if (m = /^PERMANENTFLAGS \((.*)\)/i.exec(m[2])) {
|
|
|
|
|
var idx, permFlags, keywords;
|
|
|
|
|
state.box.permFlags = permFlags = r[1].split(' ');
|
|
|
|
|
state.box.permFlags = permFlags = m[1].split(' ');
|
|
|
|
|
if ((idx = state.box.permFlags.indexOf('\\*')) > -1) {
|
|
|
|
|
state.box.newKeywords = true;
|
|
|
|
|
permFlags.splice(idx, 1);
|
|
|
|
@ -734,7 +733,7 @@ ImapConnection.prototype.append = function(data, options, cb) {
|
|
|
|
|
if (this._state.status !== STATES.BOXSELECTED)
|
|
|
|
|
throw new Error('No mailbox specified or currently selected');
|
|
|
|
|
else
|
|
|
|
|
options.mailbox = this._state.box.name
|
|
|
|
|
options.mailbox = this._state.box.name;
|
|
|
|
|
}
|
|
|
|
|
var cmd = 'APPEND "' + utils.escape(options.mailbox) + '"';
|
|
|
|
|
if ('flags' in options) {
|
|
|
|
@ -818,10 +817,10 @@ ImapConnection.prototype._fetch = function(which, uids, options) {
|
|
|
|
|
throw new Error("Expected Array of length 2 for body byte range");
|
|
|
|
|
else if (typeof opts.request.body[1] !== 'string'
|
|
|
|
|
|| !(rangeInfo = /^([\d]+)\-([\d]+)$/.exec(opts.request.body[1]))
|
|
|
|
|
|| parseInt(rangeInfo[1]) >= parseInt(rangeInfo[2]))
|
|
|
|
|
|| parseInt(rangeInfo[1], 10) >= parseInt(rangeInfo[2]), 10)
|
|
|
|
|
throw new Error("Invalid body byte range format");
|
|
|
|
|
bodyRange = '<' + parseInt(rangeInfo[1]) + '.' + parseInt(rangeInfo[2])
|
|
|
|
|
+ '>';
|
|
|
|
|
bodyRange = '<' + parseInt(rangeInfo[1], 10) + '.'
|
|
|
|
|
+ parseInt(rangeInfo[2], 10) + '>';
|
|
|
|
|
opts.request.body = opts.request.body[0];
|
|
|
|
|
}
|
|
|
|
|
if (opts.request.headers === true && opts.request.body === true) {
|
|
|
|
|