Huge News!Announcing our $40M Series B led by Abstract Ventures.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 0.2.17 to 0.2.18

21

lib/mailparser.js

@@ -5,3 +5,3 @@

* @author <a href="mailto:andris@node.ee">Andris Reinman</a>
* @version 0.2.17
* @version 0.2.18
*/

@@ -258,7 +258,6 @@

fileName = this._currentNode.meta.fileName || "attachment";
this._currentNode.meta.generatedFileName = this._generateFileName(fileName);
this._currentNode.meta.generatedFileName = this._generateFileName(this._currentNode.meta.fileName, this._currentNode.meta.contentType);
attachment = {
fileName: fileName
fileName: this._currentNode.meta.generatedFileName
};

@@ -1029,9 +1028,17 @@

* @param {String} fileName source filename
* @param {String} contentType source content type
* @returns {String} generated filename
*/
MailParser.prototype._generateFileName = function(fileName){
var ext;
MailParser.prototype._generateFileName = function(fileName, contentType){
var ext, defaultExt = "";
if(contentType){
defaultExt = mimelib.contentTypesReversed[contentType];
defaultExt = defaultExt?"."+defaultExt:"";
}
fileName = fileName || "attachment"+defaultExt;
// remove path if it is included in the filename
fileName = (fileName || "attachment").toString().split(/[\/\\]+/).pop().replace(/^\.+/,"") || "attachment";
fileName = fileName.toString().split(/[\/\\]+/).pop().replace(/^\.+/,"") || "attachment";

@@ -1038,0 +1045,0 @@ if(fileName in this._fileNames){

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

@@ -27,3 +27,3 @@ "maintainers":[

"dependencies": {
"mimelib": "0.1.11",
"mimelib": "0.1.14",
"iconv": "*"

@@ -34,4 +34,4 @@ },

},
"engines": ["node >=0.6.0"],
"engines": ["node >=0.4.0"],
"keywords": ["e-mail", "mime", "parser"]
}

@@ -8,3 +8,6 @@ var MailParser = require("../lib/mailparser").MailParser,

"Many chunks": function(test){
var encodedText = "Content-Type: text/plain; charset=utf-8\r\n\r\nÕÄ\r\nÖÜ", // \r\nÕÄÖÜ
var encodedText = "Content-Type: text/plain; charset=utf-8\r\n" +
"\r\n" +
"ÕÄ\r\n" +
"ÖÜ", // \r\nÕÄÖÜ
mail = new Buffer(encodedText, "utf-8");

@@ -27,3 +30,4 @@

"Headers only": function(test){
var encodedText = "Content-type: text/plain; charset=utf-8\r\nSubject: ÕÄÖÜ",
var encodedText = "Content-type: text/plain; charset=utf-8\r\n" +
"Subject: ÕÄÖÜ",
mail = new Buffer(encodedText, "utf-8");

@@ -41,3 +45,4 @@

"Body only": function(test){
var encodedText = "\r\n===",
var encodedText = "\r\n" +
"===",
mail = new Buffer(encodedText, "utf-8");

@@ -55,3 +60,9 @@

"Different line endings": function(test){
var encodedText = "Content-type: text/plain; charset=utf-8\rSubject: ÕÄÖÜ\n\r1234\r\nÕÄÖÜ\r\nÜÖÄÕ\n1234",
var encodedText = "Content-type: text/plain; charset=utf-8\r" +
"Subject: ÕÄÖÜ\n" +
"\r" +
"1234\r\n" +
"ÕÄÖÜ\r\n" +
"ÜÖÄÕ\n" +
"1234",
mail = new Buffer(encodedText, "utf-8");

@@ -88,3 +99,5 @@

"Plaintext encoding: Header defined": function(test){
var encodedText = "Content-Type: TEXT/PLAIN; CHARSET=UTF-8\r\n\r\nÕÄÖÜ", // \r\nÕÄÖÜ
var encodedText = "Content-Type: TEXT/PLAIN; CHARSET=UTF-8\r\n" +
"\r\n" +
"ÕÄÖÜ",
mail = new Buffer(encodedText, "utf-8");

@@ -102,3 +115,5 @@

"HTML encoding: From <meta>": function(test){
var encodedText = "Content-Type: text/html\r\n\r\n<html><head><meta charset=\"utf-8\"/></head><body>ÕÄÖÜ", // \r\nÕÄÖÜ
var encodedText = "Content-Type: text/html\r\n" +
"\r\n" +
"<html><head><meta charset=\"utf-8\"/></head><body>ÕÄÖÜ",
mail = new Buffer(encodedText, "utf-8");

@@ -117,3 +132,5 @@

"HTML encoding: Conflicting headers": function(test){
var encodedText = "Content-Type: text/html; charset=iso-8859-1\r\n\r\n<html><head><meta charset=\"utf-8\"/></head><body>ÕÄÖÜ", // \r\nÕÄÖÜ
var encodedText = "Content-Type: text/html; charset=iso-8859-1\r\n" +
"\r\n" +
"<html><head><meta charset=\"utf-8\"/></head><body>ÕÄÖÜ",
mail = new Buffer(encodedText, "utf-8");

@@ -131,3 +148,5 @@

"HTML encoding: Header defined": function(test){
var encodedText = "Content-Type: text/html; charset=iso-UTF-8\r\n\r\nÕÄÖÜ", // \r\nÕÄÖÜ
var encodedText = "Content-Type: text/html; charset=iso-UTF-8\r\n"+
"\r\n"+
"ÕÄÖÜ",
mail = new Buffer(encodedText, "utf-8");

@@ -145,3 +164,4 @@

"Mime Words": function(test){
var encodedText = "Content-type: text/plain; charset=utf-8\r\nSubject: =?iso-8859-1?Q?Avaldu?= =?iso-8859-1?Q?s_lepingu_?=\r\n =?iso-8859-1?Q?l=F5petamise?= =?iso-8859-1?Q?ks?=\r\n",
var encodedText = "Content-type: text/plain; charset=utf-8\r\n" +
"Subject: =?iso-8859-1?Q?Avaldu?= =?iso-8859-1?Q?s_lepingu_?=\r\n =?iso-8859-1?Q?l=F5petamise?= =?iso-8859-1?Q?ks?=\r\n",
mail = new Buffer(encodedText, "utf-8");

@@ -174,3 +194,6 @@

"Base64": function(test){
var encodedText = "Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: base64\r\n\r\nAAECA/3+/w==",
var encodedText = "Content-Type: application/octet-stream\r\n"+
"Content-Transfer-Encoding: base64\r\n"+
"\r\n"+
"AAECA/3+/w==",
mail = new Buffer(encodedText, "utf-8");

@@ -186,3 +209,5 @@

"8bit": function(test){
var encodedText = "Content-Type: application/octet-stream\r\n\r\nÕÄÖÜ",
var encodedText = "Content-Type: application/octet-stream\r\n"+
"\r\n"+
"ÕÄÖÜ",
mail = new Buffer(encodedText, "utf-8");

@@ -294,2 +319,74 @@

});
},
"Default name from Content-type": function(test){
var encodedText = "Content-Type: application/pdf\r\n"+
"Content-Transfer-Encoding: QUOTED-PRINTABLE\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF",
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, "attachment.pdf");
test.done();
});
},
"Default name": function(test){
var encodedText = "Content-Type: application/octet-stream\r\n"+
"Content-Transfer-Encoding: QUOTED-PRINTABLE\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF",
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, "attachment");
test.done();
});
},
"Multiple filenames - Same": function(test){
var encodedText = "Content-Type: multipart/mixed; boundary=ABC\r\n"+
"\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"test.txt\"\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"test.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, "test.txt");
test.equal(mail.attachments && mail.attachments[1] && mail.attachments[1].content && mail.attachments[1].generatedFileName, "test-1.txt");
test.done();
});
},
"Multiple filenames - Different": function(test){
var encodedText = "Content-Type: multipart/mixed; boundary=ABC\r\n"+
"\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream\r\n"+
"\r\n"+
"=00=01=02=03=FD=FE=FF\r\n"+
"--ABC\r\n"+
"Content-Type: application/octet-stream; name=\"test.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, "attachment");
test.equal(mail.attachments && mail.attachments[1] && mail.attachments[1].content && mail.attachments[1].generatedFileName, "test.txt");
test.done();
});
}

@@ -296,0 +393,0 @@

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc