You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

email-reply-parser

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-reply-parser - npm Package Compare versions

Comparing version

to
2.0.0

6

lib/email.js

@@ -22,2 +22,8 @@ class Email {

getAnswerText() {
return this.filterText((fragment) => {
return fragment.isAnswer();
});
}
filterText(filter) {

@@ -24,0 +30,0 @@ let filteredFragments = this.fragments.filter(filter);

7

lib/fragment.js
class Fragment {
constructor(content, isHidden, isSignature, isQuoted) {
constructor(content, isHidden, isSignature, isQuoted, isAnswer) {
this._content = content;

@@ -7,2 +7,3 @@ this._isHidden = isHidden;

this._isQuoted = isQuoted;
this._isAnswer = isAnswer;
}

@@ -22,2 +23,6 @@

isAnswer() {
return this._isAnswer;
}
getContent() {

@@ -24,0 +29,0 @@ return this._content;

25

lib/parser/emailparser.js

@@ -55,4 +55,4 @@ var FragmentDTO = require("./fragmentdto");

fragment = null;
} else if (line === "" && this.isQuoteHeader(last)) {
fragment.isQuoted = true;
} else if (line === "" && this.isAnswerHeader(last)) {
fragment.isAnswer = true;
this.addFragment(fragment);

@@ -93,3 +93,3 @@ fragment = null;

// remove any new lines that happen to match in the first capture group
RegexList.quoteHeadersRegex.forEach((regex) => {
RegexList.answerHeadersRegex.forEach((regex) => {
let matches = newText.match(regex);

@@ -108,8 +108,8 @@ if (matches) {

getQuoteHeadersRegex() {
return RegexList.quoteHeadersRegex;
getAnswerHeadersRegex() {
return RegexList.answerHeadersRegex;
}
setQuoteHeadersRegex(quoteHeadersRegex) {
RegexList.quoteHeadersRegex = quoteHeadersRegex;
setAnswerHeadersRegex(answerHeadersRegex) {
RegexList.answerHeadersRegex = answerHeadersRegex;

@@ -127,3 +127,4 @@ return this;

fragment.isSignature,
fragment.isQuoted
fragment.isQuoted,
fragment.isAnswer
));

@@ -135,6 +136,6 @@ });

isQuoteHeader(line) {
isAnswerHeader(line) {
let hasHeader = false;
RegexList.quoteHeadersRegex.forEach((regex) => {
RegexList.answerHeadersRegex.forEach((regex) => {
if (regex.test(this.stringReverse(line))) {

@@ -166,7 +167,7 @@ hasHeader = true;

return fragment.isQuoted === isQuoted ||
(fragment.isQuoted && (this.isQuoteHeader(line) || line === ""));
(fragment.isQuoted && (this.isAnswerHeader(line) || line === ""));
}
addFragment(fragment) {
if (fragment.isQuoted || fragment.isSignature || this.isEmpty(fragment)) {
if (fragment.isSignature || fragment.isAnswer || this.isEmpty(fragment)) {
fragment.isHidden = true;

@@ -173,0 +174,0 @@ }

@@ -7,2 +7,3 @@ class FragmentDTO {

this.isQuoted = false;
this.isAnswer = false;
}

@@ -9,0 +10,0 @@ }

@@ -20,3 +20,3 @@ let RE2;

this.quoteHeadersRegex = this.buildRe2([
this.answerHeadersRegex = this.buildRe2([
/^-*\s*(On\s.+\s.+\n?wrote:{0,1})\s{0,1}-*$/m, // On DATE, NAME <EMAIL> wrote:

@@ -23,0 +23,0 @@ /^-*\s*(Le\s.+\s.+\n?écrit\s?:{0,1})\s{0,1}-*$/m, // Le DATE, NAME <EMAIL> a écrit :

{
"name": "email-reply-parser",
"version": "1.9.4",
"version": "2.0.0",
"description": "Node library for parsing plain text email content. Based on https://github.com/willdurand/EmailReplyParser",

@@ -5,0 +5,0 @@ "main": "lib/emailreplyparser.js",