From 6bae600a3f4a0452ee7ca43634a11939de7bcc6d Mon Sep 17 00:00:00 2001 From: Slava Tsyrulnik Date: Thu, 4 Jan 2024 10:32:20 +0100 Subject: [PATCH] fix: Fix produced text address list string according to rfc 2822 (#340) --- lib/mail-parser.js | 2 +- test/simple-parser-test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mail-parser.js b/lib/mail-parser.js index 55bc9c1..c83da41 100644 --- a/lib/mail-parser.js +++ b/lib/mail-parser.js @@ -1015,7 +1015,7 @@ class MailParser extends Transform { .map(address => { let str = ''; if (address.name) { - str += address.name + (address.group ? ': ' : ''); + str += `"${address.name}"` + (address.group ? ': ' : ''); } if (address.address) { let link = address.address; diff --git a/test/simple-parser-test.js b/test/simple-parser-test.js index 0db0b53..a60938e 100644 --- a/test/simple-parser-test.js +++ b/test/simple-parser-test.js @@ -25,7 +25,7 @@ module.exports['Parse message'] = test => { } ], html: 'Andris Reinman <andris+123@kreata.ee>, andris.reinman@gmail.com', - text: 'Andris Reinman , andris.reinman@gmail.com' + text: '"Andris Reinman" , andris.reinman@gmail.com' }); test.done(); });