Browse Source

Parser: ignore invalid first line that starts with a whitespace

fork
Chotiwat Chawannakul 7 years ago
parent
commit
36f2290a0c
  1. 2
      lib/Parser.js
  2. 5
      test/test-parse-header.js

2
lib/Parser.js

@ -978,6 +978,8 @@ function parseHeader(str, noDecode) {
if (lines[i].length === 0)
break; // empty line separates message's header and body
if (lines[i][0] === '\t' || lines[i][0] === ' ') {
if (!Array.isArray(header[h]))
continue; // ignore invalid first line
// folded header content
val = lines[i];
if (!noDecode) {

5
test/test-parse-header.js

@ -70,6 +70,11 @@ var CRLF = '\r\n';
expected: { subject: [ 'รูปภาพที่ embed ในเนื้อเมลล์ไม่แสดง' ] },
what: 'Folded header value (consecutive partial base64-encoded words)'
},
{ source: [' ', CRLF,
'To: Foo', CRLF],
expected: { to: [ 'Foo' ] },
what: 'Invalid first line'
},
// header with body
{ source: ['Subject: test subject', CRLF,
'X-Another-Header: test', CRLF,

Loading…
Cancel
Save