Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.vscode
node_modules
2 changes: 1 addition & 1 deletion lib/Connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ Connection.prototype._resUntagged = function(info) {
if (toget[i] === 'X-GM-LABELS') {
var labels = info.text[keys[j]];
for (var k = 0, lenk = labels.length; k < lenk; ++k)
labels[k] = (''+labels[k]).replace(RE_ESCAPE, '\\');
labels[k] = utf7.decode((''+labels[k]).replace(RE_ESCAPE, '\\'));
}
key = FETCH_ATTR_MAP[toget[i]];
if (!key)
Expand Down
7 changes: 6 additions & 1 deletion lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@ function parseFetch(text, literals, seqno) {
var list = parseExpr(text, literals)[0], attrs = {}, m, body;
// list is [KEY1, VAL1, KEY2, VAL2, .... KEYn, VALn]
for (var i = 0, len = list.length, key, val; i < len; i += 2) {
key = list[i].toLowerCase();
// Coerce the key token to a string before lowercasing. Some servers send
// integer-shaped atoms at key positions in malformed FETCH responses;
// convStr returns a JS number for those, and Number has no .toLowerCase.
// Coercing here keeps value-position numeric atoms (RFC822.SIZE, MODSEQ,
// etc.) untouched.
key = String(list[i]).toLowerCase();
val = list[i + 1];
if (key === 'envelope')
val = parseFetchEnvelope(val);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ "name": "imap",
"version": "0.8.19",
{ "name": "@integromat/imap",
"version": "0.8.22",
"author": "Brian White <mscdex@mscdex.net>",
"description": "An IMAP module for node.js that makes communicating with IMAP servers easy",
"main": "./lib/Connection",
Expand All @@ -13,5 +13,5 @@
"engines": { "node": ">=0.8.0" },
"keywords": [ "imap", "mail", "email", "reader", "client" ],
"licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/node-imap/raw/master/LICENSE" } ],
"repository": { "type": "git", "url": "http://github.com/mscdex/node-imap.git" }
"repository": { "type": "git", "url": "https://github.com/integromat/node-imap.git" }
}
9 changes: 9 additions & 0 deletions test/test-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,15 @@ var CR = '\r', LF = '\n', CRLF = CR + LF;
],
what: 'Untagged FETCH with non-body literal'
},
{ source: ['* 1 FETCH (12345 NIL)', CRLF],
expected: [ { type: 'fetch',
num: 1,
textCode: undefined,
text: { '12345': null }
}
],
what: 'Untagged FETCH with integer-shaped key token (regression: no TypeError on .toLowerCase)'
},
{ source: ['* 12 FETCH (INTERNALDATE {2',
'6}' + CRLF + '17-Jul-1996 02:44:25 -0700)' + CRLF],
expected: [ { type: 'fetch',
Expand Down