Comparing version 3.0.4 to 3.0.5
@@ -60,3 +60,7 @@ 'use strict'; | ||
if (this.filename) { | ||
this.filename = libmime.decodeWords(this.filename); | ||
try { | ||
this.filename = libmime.decodeWords(this.filename); | ||
} catch (E) { | ||
// failed to parse filename, keep as is (most probably an unknown charset is used) | ||
} | ||
} | ||
@@ -63,0 +67,0 @@ |
@@ -38,3 +38,8 @@ 'use strict'; | ||
if (this.decoder) { | ||
this.decoder.end(); | ||
if (this.decoder.$reading) { | ||
this.decoder.$done = callback; | ||
return; | ||
} else { | ||
this.decoder.end(); | ||
} | ||
} | ||
@@ -63,3 +68,3 @@ return callback(); | ||
this.emit('node', this.createDecoder(data)); | ||
} else { | ||
} else if (this.readable) { | ||
// we don't care about this data, just pass it over to the joiner | ||
@@ -73,2 +78,3 @@ this.push(data); | ||
this.decoder = node.getDecoder(); | ||
if (['base64', 'quoted-printable'].includes(node.encoding)) { | ||
@@ -83,9 +89,15 @@ this.encoder = node.getEncoder(); | ||
let firstChunk = true; | ||
let reading = false; | ||
decoder.$reading = false; | ||
decoder.$done = false; | ||
let readFromEncoder = () => { | ||
reading = true; | ||
decoder.$reading = true; | ||
let data = encoder.read(); | ||
if (data === null) { | ||
reading = false; | ||
decoder.$reading = false; | ||
if (typeof decoder.$done === 'function') { | ||
decoder.end(); | ||
decoder.$done(); | ||
} | ||
return; | ||
@@ -96,10 +108,15 @@ } | ||
firstChunk = false; | ||
this.push(node); | ||
if (this.readable) { | ||
this.push(node); | ||
} | ||
} | ||
let writeMore = this.push({ | ||
node, | ||
type: 'body', | ||
value: data | ||
}); | ||
let writeMore = true; | ||
if (this.readable) { | ||
writeMore = this.push({ | ||
node, | ||
type: 'body', | ||
value: data | ||
}); | ||
} | ||
@@ -115,3 +132,3 @@ if (writeMore) { | ||
encoder.on('readable', () => { | ||
if (!reading) { | ||
if (!decoder.$reading) { | ||
return readFromEncoder(); | ||
@@ -124,3 +141,5 @@ } | ||
firstChunk = false; | ||
this.push(node); | ||
if (this.readable) { | ||
this.push(node); | ||
} | ||
} | ||
@@ -127,0 +146,0 @@ |
{ | ||
"name": "mailsplit", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Split email messages into an object stream", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
42356
849