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 = [];