mailparser
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -85,3 +85,7 @@ | ||
* Line counter for debugging | ||
* @private */ this._linecounter = 0; | ||
* @private */ this._lineCounter = 0; | ||
/** | ||
* Did the last chunk end with \r | ||
* @private */ this._lineFeed = false; | ||
} | ||
@@ -129,5 +133,13 @@ // inherit methods and properties of Stream | ||
if(chunk){ | ||
this._remainder += chunk.toString("binary"); | ||
chunk = chunk && chunk.toString("binary") || ""; | ||
// if the last chunk ended with \r and this one begins | ||
// with \n, it's a split line ending. Since the last \r | ||
// was already used, skip the \n | ||
if(this._lineFeed && chunk.charAt(0) == "\n"){ | ||
chunk = chunk.substr(1); | ||
} | ||
this._lineFeed = chunk.substr(-1) == "\r"; | ||
this._remainder += chunk; | ||
@@ -170,3 +182,3 @@ process.nextTick(this._process.bind(this, true)); | ||
if(this.options.debug){ | ||
console.log("LINE " + (++this._linecounter) + " ("+this._state+"): "+line); | ||
console.log("LINE " + (++this._lineCounter) + " ("+this._state+"): "+line); | ||
} | ||
@@ -196,2 +208,4 @@ | ||
} | ||
}; | ||
@@ -198,0 +212,0 @@ |
{ | ||
"name": "mailparser", | ||
"description": "Asynchronous and non-blocking parser for mime encoded e-mail messages", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"author" : "Andris Reinman", | ||
@@ -6,0 +6,0 @@ "maintainers":[ |
var MailParser = require("../lib/mailparser").MailParser, | ||
mailparser = new MailParser(); | ||
mailparser = new MailParser({ | ||
debug: true | ||
}); | ||
@@ -8,3 +10,4 @@ var email = "From: 'Sender Name' <sender@example.com>\r\n"+ | ||
"\r\n"+ | ||
"How are you today?"; | ||
"How are you today?\r\n"+ | ||
"Another line of text"; | ||
@@ -18,4 +21,6 @@ // setup an event listener when the parsing finishes | ||
// send the email source to the parser | ||
mailparser.write(email); | ||
// send the email source to the parser, char by char | ||
for(var i=0, len=email.length; i<len; i++){ | ||
mailparser.write(email.charAt(i)); | ||
} | ||
mailparser.end(); |
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
2829400
2267