From 07fd0af16d2729dfd9f43107224068010d8a74d6 Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Wed, 17 Jun 2015 14:20:03 -0400 Subject: [PATCH 1/4] Gitignore node_modules --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules From 8d32f7775bc7ff01321c8001952a29bfaa4c636a Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Wed, 17 Jun 2015 14:20:30 -0400 Subject: [PATCH 2/4] Support partial body fetches --- lib/Connection.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index 57b83384..6436dadd 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -45,7 +45,8 @@ var MAX_INT = 9007199254740992, RE_BACKSLASH = /\\/g, RE_DBLQUOTE = /"/g, RE_ESCAPE = /\\\\/g, - RE_INTEGER = /^\d+$/; + RE_INTEGER = /^\d+$/, + RE_PARTIAL_BODY = /^(TEXT)(<[0-9]+\.[0-9]+>)$/; function Connection(config) { if (!(this instanceof Connection)) @@ -820,8 +821,15 @@ Connection.prototype._fetch = function(which, uids, options) { if (!Array.isArray(bodies)) bodies = [bodies]; for (i = 0, len = bodies.length; i < len; ++i) { + var suffix = ''; + var parts = bodies[i].match(RE_PARTIAL_BODY); + if (parts) { + suffix = parts[2]; + bodies[i] = parts[1]; + } + fetching.push(parseExpr(''+bodies[i])); - cmd += ' BODY' + prefix + '[' + bodies[i] + ']'; + cmd += ' BODY' + prefix + '[' + bodies[i] + ']' + suffix; } } } else From 9a0b9fad907aac61c825916b74656dcd1eb833ab Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Thu, 25 Jun 2015 09:39:17 -0400 Subject: [PATCH 3/4] Allow partial bodies on all body types --- lib/Connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 6436dadd..909d1028 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -46,7 +46,7 @@ var MAX_INT = 9007199254740992, RE_DBLQUOTE = /"/g, RE_ESCAPE = /\\\\/g, RE_INTEGER = /^\d+$/, - RE_PARTIAL_BODY = /^(TEXT)(<[0-9]+\.[0-9]+>)$/; + RE_PARTIAL_BODY = /^([A-Za-z]+)(<[0-9]+\.[0-9]+>)$/; function Connection(config) { if (!(this instanceof Connection)) From 8dec6509c1cb4e5ad6ba272b9fe888c3603db402 Mon Sep 17 00:00:00 2001 From: Patrick McCarren Date: Mon, 29 Jun 2015 11:21:22 -0400 Subject: [PATCH 4/4] Parser: properly receive partial bodies --- lib/Parser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Parser.js b/lib/Parser.js index d6d673e8..6c4f4907 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -12,7 +12,7 @@ var CH_LF = 10, EMPTY_READCB = function(n) {}, RE_INTEGER = /^\d+$/, RE_PRECEDING = /^(?:(?:\*|A\d+) )|\+ ?/, - RE_BODYLITERAL = /BODY\[(.*)\] \{(\d+)\}$/i, + RE_BODYLITERAL = /BODY\[(.*)\](<[0-9]+>)* \{(\d+)\}$/i, RE_BODYINLINEKEY = /^BODY\[(.*)\]$/i, RE_SEQNO = /^\* (\d+)/, RE_LISTCONTENT = /^\((.*)\)$/, @@ -186,7 +186,7 @@ Parser.prototype._resUntagged = function() { var m; if (m = RE_BODYLITERAL.exec(this._buffer)) { // BODY literal -- stream it - var which = m[1], size = parseInt(m[2], 10); + var which = m[1], size = parseInt(m[3], 10); this._literallen = size; this._body = new ReadableStream(); this._body._readableState.sync = false; @@ -889,7 +889,7 @@ function decodeWords(str, state) { state.replaces = []; var bytes, m, next, i, j, leni, lenj, seq, replaces = [], lastReplace = {}; - + // join consecutive q-encoded words that have the same charset first while (m = RE_ENCWORD.exec(str)) { seq = {