From baf18ad2b82ab523a1be7cf2280f5a99a6864de0 Mon Sep 17 00:00:00 2001 From: mscdex Date: Sun, 10 Mar 2013 10:24:04 -0400 Subject: [PATCH] fix header value parsing behavior for folded lines --- lib/imap.parsers.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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();