further improvements to ID extension support

fork
Dominik Gehl 11 years ago
parent 4ff1b82b9f
commit 93337c567f

@ -310,20 +310,21 @@ Connection.prototype.id = function(identification, cb) {
if (!this.serverSupports('ID'))
throw new Error('Server does not support ID');
var cmd = 'ID';
if (identification === null)
if ((identification === null) || (Object.keys(identification).length === 0))
cmd += ' NIL';
else {
if (Object.keys(identification).length > 30)
throw new Error('Max allowed number of keys is 30');
cmd += ' (';
var kv = [];
for (var k in identification) {
if (k.length > 30)
if (Buffer.byteLength(k) > 30)
throw new Error('Max allowed key length is 30');
if (identification[k].length > 1024)
if (Buffer.byteLength(identification[k]) > 1024)
throw new Error('Max allowed value length is 1024');
cmd += '"' + escape(k) + '" "' + escape(identification[k]) + '"';
kv.push('"' + escape(k) + '"');
kv.push('"' + escape(identification[k]) + '"');
}
cmd += ')';
cmd += ' (' + kv.join(' ') + ')';
}
this._enqueue(cmd, cb);
};

Loading…
Cancel
Save