mailparser
Advanced tools
Comparing version 0.2.19 to 0.2.20
@@ -5,3 +5,3 @@ | ||
* @author <a href="mailto:andris@node.ee">Andris Reinman</a> | ||
* @version 0.2.19 | ||
* @version 0.2.20 | ||
*/ | ||
@@ -62,3 +62,3 @@ | ||
* The complete tree structure of the e-mail | ||
* @public */ this.mimeTree = this._createMimeNode(); | ||
* @public */ this.mimeTree = this._createMimeNode(); | ||
@@ -84,3 +84,3 @@ /** | ||
* This is the final mail structure object that is returned to the client | ||
* @public */ this.mailData = {}; | ||
* @public */ this.mailData = {}; | ||
@@ -396,3 +396,3 @@ /** | ||
if(!(line = this._currentNode.headers[pos]) || typeof line != "string"){ | ||
if(!(line = this._currentNode.headers[pos]) || typeof line != "string"){ | ||
return; | ||
@@ -479,5 +479,5 @@ } | ||
} | ||
this._currentNode.parsedHeaders[key].push(value); | ||
this._currentNode.parsedHeaders[key].push(this._replaceMimeWords(value)); | ||
}else{ | ||
this._currentNode.parsedHeaders[key] = value; | ||
this._currentNode.parsedHeaders[key] = this._replaceMimeWords(value); | ||
} | ||
@@ -646,3 +646,3 @@ | ||
if(name){ | ||
return this._replaceMimeWords(this._replaceMimeWords("=?"+(encoding || "us-ascii")+"?Q?" + name.replace(/%/g,"=")+"?=")); | ||
return this._replaceMimeWords(this._replaceMimeWords("=?"+(encoding || "us-ascii")+"?Q?" + name.replace(/%/g,"=")+"?=")); | ||
} | ||
@@ -748,3 +748,8 @@ } | ||
if(this._currentNode.stream){ | ||
this._currentNode.stream.write(new Buffer(line, "binary")); | ||
if(!this._currentNode.streamStarted){ | ||
this._currentNode.streamStarted = true; | ||
this._currentNode.stream.write(new Buffer(line, "binary")); | ||
}else{ | ||
this._currentNode.stream.write(new Buffer("\r\n"+line, "binary")); | ||
} | ||
}else if("content" in this._currentNode){ | ||
@@ -751,0 +756,0 @@ if(typeof this._currentNode.content!="string"){ |
{ | ||
"name": "mailparser", | ||
"description": "Asynchronous and non-blocking parser for mime encoded e-mail messages", | ||
"version": "0.2.19", | ||
"version": "0.2.20", | ||
"author" : "Andris Reinman", | ||
@@ -6,0 +6,0 @@ "maintainers":[ |
@@ -60,3 +60,3 @@ MailParser | ||
When the headers have received, "headers" is emitted. The headers have not been pre-processed (encodings changed eg.). | ||
When the headers have received, "headers" is emitted. The headers have not been pre-processed (except that mime words have been converted to UTF-8 text). | ||
@@ -63,0 +63,0 @@ mailparser.on("headers", function(headers){ |
@@ -1,2 +0,2 @@ | ||
var reporter = require('nodeunit').reporters.default; | ||
var reporter = require('nodeunit').reporters["default"]; | ||
reporter.run(['test']); |
@@ -78,2 +78,3 @@ var MailParser = require("../lib/mailparser").MailParser, | ||
var encodedText = "Content-type: multipart/mixed; boundary=ABC\r\n"+ | ||
"X-Test: =?UTF-8?Q?=C3=95=C3=84?= =?UTF-8?Q?=C3=96=C3=9C?=\r\n"+ | ||
"Subject: ABCDEF\r\n"+ | ||
@@ -90,3 +91,3 @@ "\r\n"+ | ||
test.expect(2); | ||
test.expect(3); | ||
var mailparser = new MailParser(); | ||
@@ -96,3 +97,5 @@ | ||
test.equal(headers.subject, "ABCDEF"); | ||
test.equal(headers['x-test'], "ÕÄÖÜ"); | ||
}); | ||
mailparser.end(mail); | ||
@@ -792,3 +795,3 @@ mailparser.on("end", function(mail){ | ||
}, | ||
"Stream integrity": function(test){ | ||
"Stream integrity base64": function(test){ | ||
var encodedText = "Content-type: multipart/mixed; boundary=ABC\r\n"+ | ||
@@ -826,2 +829,36 @@ "\r\n"+ | ||
}, | ||
"Stream integrity - 8bit": function(test){ | ||
var encodedText = "Content-type: multipart/mixed; boundary=ABC\r\n"+ | ||
"\r\n"+ | ||
"--ABC\r\n"+ | ||
"Content-Type: application/octet-stream\r\n"+ | ||
"Content-Transfer-Encoding: 8bit\r\n"+ | ||
"Content-Disposition: attachment\r\n"+ | ||
"\r\n"+ | ||
"ÕÄ\r\n"+"" + | ||
"ÖÜ\r\n"+ | ||
"--ABC--", | ||
expectedHash = "cad0f72629a7245dd3d2cbf41473e3ca", | ||
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(3); | ||
mailparser.on("attachment", function(attachment){ | ||
test.ok(attachment.stream, "Stream detected"); | ||
}); | ||
mailparser.end(); | ||
mailparser.on("end", function(mail){ | ||
test.equal(mail.attachments && mail.attachments[0] && mail.attachments[0].checksum, expectedHash); | ||
test.equal(mail.attachments && mail.attachments[0] && mail.attachments[0].length, 10); | ||
test.done(); | ||
}); | ||
}, | ||
"Stream multiple attachments": function(test){ | ||
@@ -828,0 +865,0 @@ var encodedText = "Content-type: multipart/mixed; boundary=ABC\r\n"+ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
568118
3151