ID support improvements

fork
Dominik Gehl 11 years ago
parent b697dfe66d
commit 4ff1b82b9f

@ -309,11 +309,24 @@ Connection.prototype.getBoxes = function(namespace, cb) {
Connection.prototype.id = function(identification, cb) {
if (!this.serverSupports('ID'))
throw new Error('Server does not support ID');
cmd = '';
for (var k in identification)
cmd += '"' + k + '" "' + identification[k] + '"';
return this._enqueue('ID (' + cmd + ')', cb);
}
var cmd = 'ID';
if (identification === null)
cmd += ' NIL';
else {
if (Object.keys(identification).length > 30)
throw new Error('Max allowed number of keys is 30');
cmd += ' (';
for (var k in identification) {
if (k.length > 30)
throw new Error('Max allowed key length is 30');
if (identification[k].length > 1024)
throw new Error('Max allowed value length is 1024');
cmd += '"' + escape(k) + '" "' + escape(identification[k]) + '"';
}
cmd += ')';
}
this._enqueue(cmd, cb);
};
Connection.prototype.openBox = function(name, readOnly, cb) {
if (this.state !== 'authenticated')

@ -334,10 +334,10 @@ function parseESearch(text, literals) {
function parseId(text, literals) {
var r = parseExpr(text, literals),
id = {};
for (var i = 0, len = r[0].length; i < len; i += 2) {
if (r[0] === null)
return null;
for (var i = 0, len = r[0].length; i < len; i += 2)
id[r[0][i].toLowerCase()] = r[0][i + 1]
}
return id;
}

Loading…
Cancel
Save