mailparser
Advanced tools
Comparing version 0.4.7 to 0.4.8
@@ -334,3 +334,3 @@ "use strict"; | ||
this.emit("attachment", attachment); | ||
this.emit("attachment", attachment, this._currentNode.parentNode); | ||
} else { | ||
@@ -523,3 +523,3 @@ this._currentNode.content = undefined; | ||
this._currentNode.meta.location = value.toLowerCase(); | ||
break; | ||
break; | ||
case "subject": | ||
@@ -526,0 +526,0 @@ this._currentNode.subject = this._encodeString(value); |
{ | ||
"name": "mailparser", | ||
"description": "Asynchronous and non-blocking parser for mime encoded e-mail messages", | ||
"version": "0.4.7", | ||
"version": "0.4.8", | ||
"author": "Andris Reinman", | ||
@@ -6,0 +6,0 @@ "maintainers": [ |
@@ -179,3 +179,3 @@ MailParser | ||
mp.on("attachment", function(attachment){ | ||
mp.on("attachment", function(attachment, mail){ | ||
var output = fs.createWriteStream(attachment.generatedFileName); | ||
@@ -182,0 +182,0 @@ attachment.stream.pipe(output); |
@@ -1295,2 +1295,36 @@ var MailParser = require("../lib/mailparser").MailParser, | ||
}, | ||
"Pass mail node to headers event": function(test){ | ||
var encodedText = "Content-type: multipart/mixed; boundary=ABC\r\n"+ | ||
"Subject: ABCDEF\r\n"+ | ||
"\r\n"+ | ||
"--ABC\r\n"+ | ||
"Content-Type: application/octet-stream\r\n"+ | ||
"Content-Transfer-Encoding: base64\r\n"+ | ||
"Content-Disposition: attachment\r\n"+ | ||
"\r\n"+ | ||
"AAECAwQFBg==\r\n"+ | ||
"--ABC--", | ||
expectedHash = "9aa461e1eca4086f9230aa49c90b0c61", | ||
mail = new Buffer(encodedText, "utf-8"); | ||
var mailparser = new MailParser({streamAttachments: true}); | ||
for(var i=0, len = mail.length; i<len; i++){ | ||
mailparser.write(new Buffer([mail[i]])); | ||
} | ||
test.expect(2); | ||
mailparser.on("attachment", function(attachment, email){ | ||
test.equal(email.subject, "ABCDEF"); | ||
}); | ||
mailparser.end(); | ||
mailparser.on("end", function(mail){ | ||
test.ok(1, "Done"); | ||
test.done(); | ||
}); | ||
}, | ||
"Detect Content-Type by filename": function(test){ | ||
@@ -1297,0 +1331,0 @@ var encodedText = "Content-type: multipart/mixed; boundary=ABC\r\n"+ |
137595
2995