|
|
|
@ -36,9 +36,7 @@ var MAX_INT = 9007199254740992,
|
|
|
|
|
RE_INVALID_KW_CHARS = /[\(\)\{\\\"\]\%\*\x00-\x20\x7F]/,
|
|
|
|
|
RE_NUM_RANGE = /^(?:[\d]+|\*):(?:[\d]+|\*)$/,
|
|
|
|
|
RE_BACKSLASH = /\\/g,
|
|
|
|
|
RE_BACKSLASH_ESC = /\\\\/g,
|
|
|
|
|
RE_DBLQUOTE = /"/g,
|
|
|
|
|
RE_DBLQUOTE_ESC = /\\"/g,
|
|
|
|
|
RE_INTEGER = /^\d+$/;
|
|
|
|
|
|
|
|
|
|
function Connection(config) {
|
|
|
|
@ -541,10 +539,10 @@ Connection.prototype._move = function(which, uids, boxTo, cb) {
|
|
|
|
|
ccb(err, info);
|
|
|
|
|
}
|
|
|
|
|
} else if (task === 2) {
|
|
|
|
|
function cbMarkDel(e) {
|
|
|
|
|
var cbMarkDel = function(e) {
|
|
|
|
|
++task;
|
|
|
|
|
ccb(e, info);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
if (which)
|
|
|
|
|
self.addFlags(uids, 'Deleted', cbMarkDel);
|
|
|
|
|
else
|
|
|
|
@ -854,7 +852,7 @@ Connection.prototype.__defineGetter__('seq', function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
var type = info.type;
|
|
|
|
|
var type = info.type, i, len, box, attrs;
|
|
|
|
|
|
|
|
|
|
if (type === 'bye')
|
|
|
|
|
this._sock.end();
|
|
|
|
@ -932,7 +930,7 @@ Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
this._box.keywords = keywords = permFlags.filter(function(f) {
|
|
|
|
|
return (f[0] !== '\\');
|
|
|
|
|
});
|
|
|
|
|
for (var i = 0, len = keywords.length; i < len; ++i)
|
|
|
|
|
for (i = 0, len = keywords.length; i < len; ++i)
|
|
|
|
|
permFlags.splice(permFlags.indexOf(keywords[i]), 1);
|
|
|
|
|
this._box.permFlags = permFlags.map(function(f) {
|
|
|
|
|
return f.substr(1).toLowerCase();
|
|
|
|
@ -946,7 +944,7 @@ Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
if (this._curReq.cbargs.length === 0)
|
|
|
|
|
this._curReq.cbargs.push({});
|
|
|
|
|
|
|
|
|
|
var box = {
|
|
|
|
|
box = {
|
|
|
|
|
attribs: info.text.flags.map(function(attr) {
|
|
|
|
|
return attr.substr(1);
|
|
|
|
|
}).filter(function(attr) {
|
|
|
|
@ -955,15 +953,16 @@ Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
delimiter: info.text.delimiter,
|
|
|
|
|
children: null,
|
|
|
|
|
parent: null
|
|
|
|
|
},
|
|
|
|
|
name = info.text.name,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var name = info.text.name,
|
|
|
|
|
curChildren = this._curReq.cbargs[0];
|
|
|
|
|
|
|
|
|
|
if (box.delimiter) {
|
|
|
|
|
var path = name.split(box.delimiter),
|
|
|
|
|
parent = null;
|
|
|
|
|
name = path.pop();
|
|
|
|
|
for (var i = 0, len = path.length; i < len; ++i) {
|
|
|
|
|
for (i = 0, len = path.length; i < len; ++i) {
|
|
|
|
|
if (!curChildren[path[i]])
|
|
|
|
|
curChildren[path[i]] = {};
|
|
|
|
|
if (!curChildren[path[i]].children)
|
|
|
|
@ -978,7 +977,7 @@ Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
curChildren[name] = box;
|
|
|
|
|
}
|
|
|
|
|
} else if (type === 'status') {
|
|
|
|
|
var box = {
|
|
|
|
|
box = {
|
|
|
|
|
name: info.text.name,
|
|
|
|
|
uidvalidity: 0,
|
|
|
|
|
messages: {
|
|
|
|
@ -986,7 +985,8 @@ Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
new: 0,
|
|
|
|
|
unseen: 0
|
|
|
|
|
}
|
|
|
|
|
}, attrs = info.text.attrs;
|
|
|
|
|
};
|
|
|
|
|
attrs = info.text.attrs;
|
|
|
|
|
|
|
|
|
|
if (attrs) {
|
|
|
|
|
if (attrs.recent !== undefined)
|
|
|
|
@ -1003,7 +1003,7 @@ Connection.prototype._resUntagged = function(info) {
|
|
|
|
|
var msg = this._curReq.fetchCache[info.num],
|
|
|
|
|
keys = Object.keys(info.text),
|
|
|
|
|
keyslen = keys.length,
|
|
|
|
|
attrs, toget, msgEmitter, i, j;
|
|
|
|
|
toget, msgEmitter, j;
|
|
|
|
|
|
|
|
|
|
if (msg === undefined) {
|
|
|
|
|
// simple case -- no bodies were streamed
|
|
|
|
@ -1069,7 +1069,7 @@ Connection.prototype._resTagged = function(info) {
|
|
|
|
|
errtext = req.oauthError;
|
|
|
|
|
else
|
|
|
|
|
errtext = info.text;
|
|
|
|
|
var err = new Error(errtext);
|
|
|
|
|
err = new Error(errtext);
|
|
|
|
|
err.textCode = info.textCode;
|
|
|
|
|
err.source = 'protocol';
|
|
|
|
|
} else if (this._box) {
|
|
|
|
@ -1205,16 +1205,17 @@ Connection.prototype._login = function() {
|
|
|
|
|
return reentry(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cmd;
|
|
|
|
|
if (self.serverSupports('AUTH=XOAUTH') && self._config.xoauth) {
|
|
|
|
|
self._caps = undefined;
|
|
|
|
|
var cmd = 'AUTHENTICATE XOAUTH';
|
|
|
|
|
cmd = 'AUTHENTICATE XOAUTH';
|
|
|
|
|
// are there any servers that support XOAUTH/XOAUTH2 and not SASL-IR?
|
|
|
|
|
//if (self.serverSupports('SASL-IR'))
|
|
|
|
|
cmd += ' ' + escape(self._config.xoauth);
|
|
|
|
|
self._enqueue(cmd, checkCaps);
|
|
|
|
|
} else if (self.serverSupports('AUTH=XOAUTH2') && self._config.xoauth2) {
|
|
|
|
|
self._caps = undefined;
|
|
|
|
|
var cmd = 'AUTHENTICATE XOAUTH2';
|
|
|
|
|
cmd = 'AUTHENTICATE XOAUTH2';
|
|
|
|
|
//if (self.serverSupports('SASL-IR'))
|
|
|
|
|
cmd += ' ' + escape(self._config.xoauth2);
|
|
|
|
|
self._enqueue(cmd, checkCaps);
|
|
|
|
@ -1246,8 +1247,8 @@ Connection.prototype._starttls = function() {
|
|
|
|
|
|
|
|
|
|
var tlsOptions = {};
|
|
|
|
|
|
|
|
|
|
for (var k in config.tlsOptions)
|
|
|
|
|
tlsOptions[k] = config.tlsOptions[k];
|
|
|
|
|
for (var k in this._config.tlsOptions)
|
|
|
|
|
tlsOptions[k] = this._config.tlsOptions[k];
|
|
|
|
|
tlsOptions.socket = self._sock;
|
|
|
|
|
|
|
|
|
|
self._sock = tls.connect(tlsOptions, function() {
|
|
|
|
|