diff --git a/lib/imap.parsers.js b/lib/imap.parsers.js index a3c29cf..48f2c82 100644 --- a/lib/imap.parsers.js +++ b/lib/imap.parsers.js @@ -1,8 +1,7 @@ var utils = require('./imap.utilities'); var reCRLF = /\r\n/g, - reHdr = /^([^:]+):\s?(.+)?$/, - reHdrFold = /^\s+(.+)$/; + reHdr = /^([^:]+):[ \t]?(.+)?$/; exports.convStr = function(str, literals) { if (str[0] === '"') @@ -29,8 +28,9 @@ exports.parseHeaders = function(str) { continue; if (lines[i][0] === '\t' || lines[i][0] === ' ') { // folded header content - m = reHdrFold.exec(lines[i]); - headers[h][headers[h].length - 1] += m[1]; + // RFC2822 says to just remove the CRLF and not the whitespace following + // it, so we follow the RFC and include the leading whitespace ... + headers[h][headers[h].length - 1] += lines[i]; } else { m = reHdr.exec(lines[i]); h = m[1].toLowerCase();