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 2.2.0 to 2.3.0

68

lib/mail-parser.js

@@ -5,7 +5,7 @@ 'use strict';

const libmime = require('libmime');
const addressparser = require('addressparser');
const addressparser = require('nodemailer/lib/addressparser');
const Transform = require('stream').Transform;
const Splitter = mailsplit.Splitter;
const punycode = require('punycode');
const FlowedDecoder = require('./flowed-decoder');
const FlowedDecoder = require('mailsplit/lib/flowed-decoder');
const StreamHash = require('./stream-hash');

@@ -132,13 +132,23 @@ const iconv = require('iconv-lite');

}
this.waitingEnd = () => this.cleanup(done);
this.waitingEnd = () => {
this.cleanup(done);
};
}
cleanup(done) {
if (this.curnode && this.curnode.decoder) {
let finish = () => {
let t = this.getTextContent();
this.push(t);
done();
};
if (this.curnode && this.curnode.decoder && this.curnode.decoder.readable) {
(this.curnode.contentStream || this.curnode.decoder).once('end', () => {
finish();
});
this.curnode.decoder.end();
} else {
setImmediate(() => {
finish();
});
}
setImmediate(() => {
this.push(this.getTextContent());
done();
});
}

@@ -631,5 +641,7 @@

}
if (data.filename) {
attachment.filename = data.filename;
}
if (node.headers.has('content-id')) {

@@ -641,2 +653,3 @@ attachment.contentId = [].concat(node.headers.get('content-id') || []).shift();

.trim();
// check if the attachment is "related" to text content like an embedded image etc
let parentNode = node;

@@ -656,3 +669,3 @@ while ((parentNode = parentNode.parent)) {

let chunklen = 0;
let contentStream = node.decoder;
node.contentStream = node.decoder;

@@ -665,3 +678,3 @@ if (node.contentType === 'text/plain') {

let charset = node.charset || 'windows-1257';
let charset = node.charset || 'utf-8';
//charset = charset || 'windows-1257';

@@ -679,7 +692,7 @@

let decodeStream = iconv.decodeStream(charset);
contentStream.on('error', err => {
node.contentStream.on('error', err => {
decodeStream.emit('error', err);
});
contentStream.pipe(decodeStream);
contentStream = decodeStream;
node.contentStream.pipe(decodeStream);
node.contentStream = decodeStream;
} catch (E) {

@@ -690,5 +703,5 @@ // do not decode charset

contentStream.on('readable', () => {
node.contentStream.on('readable', () => {
let chunk;
while ((chunk = contentStream.read()) !== null) {
while ((chunk = node.contentStream.read()) !== null) {
if (typeof chunk === 'string') {

@@ -702,3 +715,3 @@ chunk = Buffer.from(chunk);

contentStream.once('end', () => {
node.contentStream.once('end', () => {
node.textContent = Buffer.concat(chunks, chunklen)

@@ -709,3 +722,3 @@ .toString()

contentStream.once('error', err => {
node.contentStream.once('error', err => {
this.emit('error', err);

@@ -717,2 +730,3 @@ });

}
case 'data':

@@ -722,2 +736,3 @@ if (this.curnode && this.curnode.decoder) {

}
if (this.waitUntilAttachmentEnd) {

@@ -727,2 +742,3 @@ this.attachmentCallback = done;

}
// multipart message structure

@@ -733,2 +749,3 @@ // this is not related to any specific 'node' block as it includes

break;
case 'body':

@@ -740,2 +757,3 @@ if (this.curnode && this.curnode.decoder) {

}
// Leaf element body. Includes the body for the last 'node' block. You might

@@ -861,2 +879,3 @@ // have several 'body' calls for a single 'node' block

});
try {

@@ -867,2 +886,3 @@ if (linkify.pretest(encoded)) {

let last = 0;
links.forEach(link => {

@@ -873,16 +893,4 @@ if (last < link.index) {

let url = he
// encode special chars
.encode(link.url, {
useNamedReferences: true
});
result.push(`<a href="${link.url}">${link.text}</a>`);
let text = he
// encode special chars
.encode(link.text, {
useNamedReferences: true
});
result.push(`<a href="${url}">${text}</a>`);
last = link.lastIndex;

@@ -889,0 +897,0 @@ });

@@ -31,3 +31,12 @@ 'use strict';

parser.on('data', data => {
let reading = false;
let reader = () => {
reading = true;
let data = parser.read();
if (data === null) {
reading = false;
return;
}
if (data.type === 'text') {

@@ -57,4 +66,13 @@ Object.keys(data).forEach(key => {

data.release();
reader();
});
} else {
reader();
}
};
parser.on('readable', () => {
if (!reading) {
reader();
}
});

@@ -61,0 +79,0 @@

{
"name": "mailparser",
"version": "2.2.0",
"version": "2.3.0",
"description": "Parse e-mails",

@@ -12,18 +12,18 @@ "main": "index.js",

"dependencies": {
"addressparser": "1.0.1",
"he": "^1.1.1",
"html-to-text": "3.3.0",
"iconv-lite": "0.4.19",
"libmime": "3.1.0",
"he": "1.1.1",
"html-to-text": "4.0.0",
"iconv-lite": "0.4.23",
"libmime": "4.0.0",
"linkify-it": "2.0.3",
"mailsplit": "4.1.2",
"tlds": "1.199.0"
"mailsplit": "4.2.1",
"tlds": "1.203.1"
},
"devDependencies": {
"ajv": "^6.5.2",
"eslint-config-nodemailer": "^1.2.0",
"grunt": "^1.0.2",
"grunt": "^1.0.3",
"grunt-cli": "^1.2.0",
"grunt-contrib-nodeunit": "^1.0.0",
"grunt-eslint": "^20.1.0",
"libbase64": "^1.0.2",
"grunt-contrib-nodeunit": "^2.0.0",
"grunt-eslint": "^21.0.0",
"libbase64": "^1.0.3",
"libqp": "^1.1.0",

@@ -30,0 +30,0 @@ "random-message": "^1.1.0"

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