From 16dfe6a894027c409b3b12f47a743bf95026632b Mon Sep 17 00:00:00 2001 From: Alex Indigo Date: Wed, 31 Jul 2013 12:28:06 -0700 Subject: [PATCH] #276 Made parseHeader parse only header and ignore message's body + test. --- lib/Parser.js | 2 +- test/test-parse-header.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Parser.js b/lib/Parser.js index 35e37d8..7efa3ab 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -719,7 +719,7 @@ function parseHeader(str, noDecode) { for (var i = 0; i < len; ++i) { if (lines[i].length === 0) - continue; + break; // empty line separates message's header and body if (lines[i][0] === '\t' || lines[i][0] === ' ') { // folded header content val = lines[i]; diff --git a/test/test-parse-header.js b/test/test-parse-header.js index 9caf7de..2109599 100644 --- a/test/test-parse-header.js +++ b/test/test-parse-header.js @@ -38,6 +38,15 @@ var CRLF = '\r\n'; expected: { subject: [ '测试题目与中国信 long subjects are not OK 12 345678901234567890123456789012345678901234567890123456789012345678901234567890' ] }, what: 'Folded header value (one adjacent, one non-adjacent MIME encoded-words)' }, + // header with body + { source: ['Subject: test subject', CRLF, + 'X-Another-Header: test', CRLF, + CRLF, + 'This is body: Not a header', CRLF], + expected: { subject: [ 'test subject' ], 'x-another-header': [ 'test' ] }, + what: 'Header with the body' + }, + ].forEach(function(v) { var result;