From 9a961cc35c1698e59ac1546cf33dadd0957d40cb Mon Sep 17 00:00:00 2001 From: Brian White Date: Wed, 16 Oct 2013 21:13:00 -0400 Subject: [PATCH] Connection: add guard when updating name of currently open box during rename --- lib/Connection.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index f4c9b24..ca1f37f 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -410,12 +410,6 @@ Connection.prototype.delBox = function(name, cb) { }; Connection.prototype.renameBox = function(oldname, newname, cb) { - var destname = newname; - if (this._box - && oldname === this._box.name - && oldname.toUpperCase() !== 'INBOX') - destname = ''+oldname; - var encoldname = escape(utf7.encode(''+oldname)), encnewname = escape(utf7.encode(''+newname)), self = this; @@ -424,8 +418,14 @@ Connection.prototype.renameBox = function(oldname, newname, cb) { function(err) { if (err) return cb(err); - self._box.name = destname; - cb(err, self._box); + + if (self._box + && self._box.name === oldname + && oldname.toUpperCase() !== 'INBOX') { + self._box.name = newname; + cb(err, self._box); + } else + cb(); } ); };