Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
node-email-reply-parser
Advanced tools
Parses emails to remove replies and other potentially unwanted data
A port of willdurand/EmailReplyParser (which is a port of github/email_reply_parser) to nodejs
willdurand's port of the Github library supports multiple spoken languages and has some enhanced parsing and therefore was used as a template for this library.
This package can be found on npm:
npm install node-email-reply-parser
Note: This package is ES6 compatible and does not transpile automatically.
var replyParser = require("node-email-reply-parser");
var email = replyParser(emailContent);
email
has two primary methods:
getFragments()
: returns all the fragments of the emailgetVisibleText()
: returns the text that is considered 'visible'getVisibleText()
accepts an optional options object:
getVisibleText({aggressive: true})
Setting aggressive
to true will make the parser assume that any fragment which is not hidden, but which is both preceded and followed by a hidden fragment, should not be visible. This works around the issue of clients breaking quoted text into multiple lines (e.g. Gmail).
Using aggressive mode runs the risk of losing visible lines which are interspersed with quoted lines, but is useful when parsing e.g. emails from a 'reply by email' feature which contain a large block of quoted text.
A fragment has the following functions:
getContent()
: returns the content of the fragmentisSignature()
: returns whether or not the fragment is likely a signatureisQuoted()
: returns whether or not the fragment is likely a quoteisHidden()
: returns whether or not the text is considered 'hidden'isEmpty()
: returns whether or not the fragment has any contentPassing true
as the second argument to replyParser
will have the return value be just the visible text:
$visibleText = replyParser($emailContent, true);
The parser is not able to pick up some of the edge cases. They are outlined below.
Quoted headers aren't picked up if there's an extra line break:
On <date>, <author> wrote:
> blah
They also aren't picked up if the email client breaks it up into multiple lines, like gmail and it's 80 column automatic limit:
On <date>, <author>
wrote:
> blah
Lines starting with -
or _
sometimes mark the beginning of signatures:
Hello
--
Rick
Not everyone follows this convention:
Hello
Mr Rick Olson
Galactic President Superstar Mc Awesomeville
GitHub
**********************DISCLAIMER***********************************
* Note: blah blah blah *
**********************DISCLAIMER***********************************
Apparently, prefixing lines with >
isn't universal either:
Hello
--
Rick
________________________________________
From: Bob [reply@reply.github.com]
Sent: Monday, March 14, 2011 6:16 PM
To: Rick
Install the required dependencies:
npm install --dev
Run the tests:
npm test
Please see the CONTRIBUTING.md file.
node-email-reply-parser is released under the MIT Licenses. Please see the bundled LICENSE file for details.
FAQs
Parses emails to remove replies and other potentially unwanted data
The npm package node-email-reply-parser receives a total of 22,520 weekly downloads. As such, node-email-reply-parser popularity was classified as popular.
We found that node-email-reply-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.