New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mailparser

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailparser - npm Package Compare versions

Comparing version

to
0.3.6

16

lib/mailparser.js

@@ -934,3 +934,3 @@

if(this.mimeTree.messageId){
returnValue.messageId = this.mimeTree.messageId;
returnValue.messageId = this.mimeTree.messageId;
}

@@ -1249,3 +1249,3 @@

MailParser.prototype._generateFileName = function(fileName, contentType){
var ext, defaultExt = "";
var ext, defaultExt = "", fileRootName;

@@ -1261,14 +1261,16 @@ if(contentType){

fileName = fileName.toString().split(/[\/\\]+/).pop().replace(/^\.+/,"") || "attachment";
fileRootName = fileName.replace(/(?:\-\d+)+(\.[^.]*)$/, "$1") || "attachment";
if(fileName in this._fileNames){
this._fileNames[fileName]++;
if(fileRootName in this._fileNames){
this._fileNames[fileRootName]++;
ext = fileName.substr((fileName.lastIndexOf(".") || 0)+1);
if(ext == fileName){
fileName += "-" + this._fileNames[fileName];
fileName += "-" + this._fileNames[fileRootName];
}else{
fileName = fileName.substr(0, fileName.length - ext.length - 1) + "-" + this._fileNames[fileName] + "." + ext;
fileName = fileName.substr(0, fileName.length - ext.length - 1) + "-" + this._fileNames[fileRootName] + "." + ext;
}
}else{
this._fileNames[fileName] = 0;
this._fileNames[fileRootName] = 0;
}
return fileName;

@@ -1275,0 +1277,0 @@ };

{
"name": "mailparser",
"description": "Asynchronous and non-blocking parser for mime encoded e-mail messages",
"version": "0.3.5",
"version": "0.3.6",
"author" : "Andris Reinman",

@@ -6,0 +6,0 @@ "maintainers":[

@@ -5,2 +5,3 @@ MailParser

[![Build Status](https://secure.travis-ci.org/andris9/mailparser.png)](http://travis-ci.org/andris9/mailparser)
[![NPM version](https://badge.fury.io/js/mailparser.png)](http://badge.fury.io/js/mailparser)

@@ -7,0 +8,0 @@ **MailParser** is an asynchronous and non-blocking parser for

@@ -621,2 +621,34 @@ var MailParser = require("../lib/mailparser").MailParser,

},
"Multiple filenames - with number": function(test){
var encodedText = "Content-Type: multipart/mixed; boundary=ABC\r\n"+
"\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"somename.txt\"\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"somename-1.txt\"\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"somename.txt\"\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"somename-1-1.txt\"\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF\r\n"+
"--ABC--",
mail = new Buffer(encodedText, "utf-8");
var mailparser = new MailParser();
mailparser.end(mail);
mailparser.on("end", function(mail){
test.equal(mail.attachments && mail.attachments[0] && mail.attachments[0].content && mail.attachments[0].generatedFileName, "somename.txt");
test.equal(mail.attachments && mail.attachments[1] && mail.attachments[1].content && mail.attachments[1].generatedFileName, "somename-1-1.txt");
test.equal(mail.attachments && mail.attachments[2] && mail.attachments[2].content && mail.attachments[2].generatedFileName, "somename-2.txt");
test.equal(mail.attachments && mail.attachments[3] && mail.attachments[3].content && mail.attachments[3].generatedFileName, "somename-1-1-3.txt");
test.done();
});
},
"Generate filename from Content-Type": function(test){

@@ -1306,2 +1338,2 @@ var encodedText = "Content-Type: multipart/mixed; boundary=ABC\r\n"+

}
};
};