diff --git a/lib/Parser.js b/lib/Parser.js index d6d673e..a38da29 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -499,7 +499,7 @@ function parseBodyStructure(cur, literals, prefix, partID) { }; } else { // type information for malformed multipart body - part = { type: cur[0].toLowerCase(), params: null }; + part = { type: cur[0] ? cur[0].toLowerCase() : null, params: null }; cur.splice(1, 0, null); ++partLen; next = 2; diff --git a/test/test-parse-bodystructure.js b/test/test-parse-bodystructure.js index ae826ef..3edf0aa 100644 --- a/test/test-parse-bodystructure.js +++ b/test/test-parse-bodystructure.js @@ -35,6 +35,17 @@ var assert = require('assert'), ], what: 'RFC3501 example #1' }, + { source: 'NIL NIL ("CHARSET" "GB2312") NIL NIL NIL 176 NIL NIL NIL', + expected: [ { type: null, + params: null, + disposition: null, + language: [ 'CHARSET', 'GB2312' ], + location: null, + extensions: null + } + ], + what: 'Issue 477' + }, { source: '"TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 3028 92', expected: [ { partID: '1', type: 'text',