From 41554f5188ca021a739ee0ecc56b099274ca9dd6 Mon Sep 17 00:00:00 2001 From: mscdex Date: Sun, 14 Jul 2013 00:37:59 -0400 Subject: [PATCH] Connection: default to lowercased version of original attribute name if no mapping exists --- lib/Connection.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index a8efbd8..e2d08eb 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -20,12 +20,7 @@ var MAX_INT = 9007199254740992, 'RFC822.SIZE': 'size', 'BODY': 'struct', 'BODYSTRUCTURE': 'struct', - 'UID': 'uid', - 'INTERNALDATE': 'date', - 'FLAGS': 'flags', - 'X-GM-THRID': 'x-gm-thrid', - 'X-GM-MSGID': 'x-gm-msgid', - 'X-GM-LABELS': 'x-gm-labels' + 'INTERNALDATE': 'date' }, CRLF = '\r\n', RE_CMD = /^([^ ]+)(?: |$)/, @@ -1217,7 +1212,7 @@ Connection.prototype._resUntagged = function(info) { var msg = this._curReq.fetchCache[info.num], keys = Object.keys(info.text), keyslen = keys.length, - toget, msgEmitter, j; + toget, msgEmitter, j, key; if (msg === undefined) { // simple case -- no bodies were streamed @@ -1257,7 +1252,10 @@ Connection.prototype._resUntagged = function(info) { for (var k = 0, lenk = labels.length; k < lenk; ++k) labels[k] = (''+labels[k]).replace(RE_ESCAPE, '\\'); } - attrs[FETCH_ATTR_MAP[toget[i]]] = info.text[keys[j]]; + key = FETCH_ATTR_MAP[toget[i]]; + if (!key) + key = toget[i].toLowerCase(); + attrs[key] = info.text[keys[j]]; } toget.splice(i, 1); break;