Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nodemailer/mailparser
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Apr 25, 2024
2 parents 4a15157 + 4e9b1c8 commit 9d7a2b7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [3.7.0](https://github.com/nodemailer/mailparser/compare/v3.6.9...v3.7.0) (2024-04-01)


### Features

* **events:** Emit a new headerLines event to gain access the raw headers ([#364](https://github.com/nodemailer/mailparser/issues/364)) ([d33d7ec](https://github.com/nodemailer/mailparser/commit/d33d7ec4b8e32a4eb7a9a664cec5fdb545c274af))

## [3.6.9](https://github.com/nodemailer/mailparser/compare/v3.6.8...v3.6.9) (2024-02-29)


Expand Down
4 changes: 4 additions & 0 deletions lib/mail-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,10 @@ class MailParser extends Transform {
}
});
this.emit('headers', node.headers);

if (node.headerLines) {
this.emit('headerLines', node.headerLines);
}
}

if (data.contentType === 'message/rfc822' && data.messageNode) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mailparser",
"version": "3.6.9",
"version": "3.7.0",
"description": "Parse e-mails",
"main": "index.js",
"scripts": {
Expand Down
27 changes: 27 additions & 0 deletions test/mail-parser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,33 @@ exports['General tests'] = {
});
},

'HeaderLines event': test => {
let encodedText = 'X-Test: =?UTF-8?Q?=C3=95=C3=84?= =?UTF-8?Q?=C3=96=C3=9C?=\r\n' + 'Subject: ABCDEF',
mail = Buffer.from(encodedText, 'utf-8');

test.expect(3);
let mailparser = new MailParser();

mailparser.on('headerLines', headerLines => {
test.equal(!!headerLines.find(({ line }) => line === 'X-Test: =?UTF-8?Q?=C3=95=C3=84?= =?UTF-8?Q?=C3=96=C3=9C?='), true);
test.equal(!!headerLines.find(({ line }) => line === 'Subject: ABCDEF'), true);
});

mailparser.end(mail);
mailparser.on('data', data => {
if (data && data.release) {
data.content.on('data', () => false);
data.content.on('end', () => false);
data.release();
}
});

mailparser.on('end', () => {
test.ok(1, 'Parsing ended');
test.done();
});
},

'No priority': test => {
let encodedText = 'Content-type: text/plain; charset=utf-8\r\nSubject: ÕÄÖÜ\n\r\n1234',
mail = Buffer.from(encodedText, 'utf-8');
Expand Down

0 comments on commit 9d7a2b7

Please sign in to comment.