From bad60cf479db1bef333b4d16b419c7111d012893 Mon Sep 17 00:00:00 2001 From: mscdex Date: Fri, 28 Jun 2013 13:13:11 -0400 Subject: [PATCH] Parser: fix text code parsing for tagged responses --- lib/Connection.js | 6 ++++-- lib/Parser.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index 4d0b36c..f2ebdcc 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -939,8 +939,10 @@ Connection.prototype._resTagged = function(info) { err.textCode = info.textCode; err.source = 'protocol'; } else if (this._box) { - if (req.type === 'EXAMINE' || req.type === 'SELECT') - this._box.readOnly = (info.textCode.toUpperCase() === 'READ-ONLY'); + if (req.type === 'EXAMINE' || req.type === 'SELECT') { + this._box.readOnly = (typeof info.textCode === 'string' + && info.textCode.toUpperCase() === 'READ-ONLY'); + } // According to RFC 3501, UID commands do not give errors for // non-existant user-supplied UIDs, so give the callback empty results diff --git a/lib/Parser.js b/lib/Parser.js index 216026d..86a535f 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -141,7 +141,7 @@ Parser.prototype._resTagged = function() { var m = RE_TAGGED.exec(this._buffer), tagnum = parseInt(m[1], 10), type = m[2].toLowerCase(), - textCode = (m[3] ? parseExpr(m[3], this._literals) : m[3]), + textCode = (m[3] ? parseTextCode(m[3], this._literals) : m[3]), text = m[4]; this._literals = [];