mailparser
Advanced tools
Comparing version
@@ -217,3 +217,3 @@ | ||
}else if(this.currentNode.meta.transferEncoding == "quoted-printable"){ | ||
this.currentNode.stream = new Streams.QPStream(this.currentNode.meta.charset); | ||
this.currentNode.stream = new Streams.QPStream("binary"); | ||
}else{ | ||
@@ -226,3 +226,3 @@ this.currentNode.stream = new Streams.BinaryStream(); | ||
}else{ | ||
this.currentNode.content = ""; | ||
this.currentNode.content = undefined; | ||
} | ||
@@ -297,3 +297,2 @@ } | ||
} | ||
// handle text or attachment line | ||
@@ -603,3 +602,7 @@ if(["text/plain", "text/html"].indexOf(this.currentNode.meta.contentType || "")>=0 && | ||
}else if("content" in this.currentNode){ | ||
this.currentNode.content += "\n" + line; | ||
if(typeof this.currentNode.content!="string"){ | ||
this.currentNode.content = line; | ||
}else{ | ||
this.currentNode.content += "\n" + line; | ||
} | ||
} | ||
@@ -627,4 +630,3 @@ }; | ||
if(this.currentNode.meta.transferEncoding == "quoted-printable"){ | ||
this.currentNode.content = new Buffer(mimelib.decodeQuotedPrintable(this.currentNode.content, false, this.currentNode.meta.charset), "utf-8"); | ||
this.currentNode.content = this.convertString(this.currentNode.content, "utf-8", this.currentNode.meta.charset); | ||
this.currentNode.content = mimelib.decodeQuotedPrintable(this.currentNode.content, false, "binary"); | ||
}else if(this.currentNode.meta.transferEncoding == "base64"){ | ||
@@ -631,0 +633,0 @@ this.currentNode.content = new Buffer(this.currentNode.content.replace(/[^\w\+\/=]/g,''), "base64"); |
@@ -62,3 +62,3 @@ var Stream = require('stream').Stream, | ||
this.charset = charset || "UTF-8"; | ||
this.current = ""; | ||
this.current = undefined; | ||
} | ||
@@ -89,10 +89,15 @@ utillib.inherits(QPStream, Stream); | ||
this.current += data; | ||
if(typeof this.current !="string"){ | ||
this.current = data; | ||
}else{ | ||
this.current += "\n" + data; | ||
} | ||
}; | ||
QPStream.prototype.flush = function(){ | ||
console.log(this.current); | ||
var iconv, buffer = mimelib.decodeQuotedPrintable(this.current, false, this.charset); | ||
if(this.charset.toLowerCase() != "utf-8"){ | ||
if(this.charset.toLowerCase() == "binary"){ | ||
; // do nothing | ||
}else if(this.charset.toLowerCase() != "utf-8"){ | ||
iconv = new Iconv('UTF-8', this.charset+"//TRANSLIT//IGNORE"); | ||
@@ -99,0 +104,0 @@ buffer = iconv.convert(buffer); |
{ | ||
"name": "mailparser", | ||
"description": "Asynchronous and non-blocking parser for mime encoded e-mail messages", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author" : "Andris Reinman", | ||
@@ -24,3 +24,3 @@ "maintainers":[ | ||
"dependencies": { | ||
"mimelib": "0.1.7", | ||
"mimelib": "0.1.8", | ||
"iconv": "*" | ||
@@ -27,0 +27,0 @@ }, |
@@ -6,3 +6,3 @@ var MailParser = require("../lib/mailparser").MailParser, | ||
var inp = fs.createReadStream("large.eml"), | ||
var inp = fs.createReadStream("applequoted.eml"), | ||
out = new MailParser({ | ||
@@ -9,0 +9,0 @@ streamAttachments: true |
Sorry, the diff of this file is not supported yet
2772651
02199
0.37%+ Added
- Removed
Updated