From 62b727fb619c744a0665d8a30dbf9727789801b7 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 10 Jan 2023 10:36:22 +0000 Subject: [PATCH] Merge pull request #11008 from overleaf/msm-fix-email-helper-group [web] Prevent NPE parsing RFC5322 email groups GitOrigin-RevId: 57fa7dc523b94c44afdd45a790ff6c3e62e45214 --- services/web/app/src/Features/Helpers/EmailHelper.js | 2 +- services/web/test/unit/src/HelperFiles/EmailHelperTests.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/web/app/src/Features/Helpers/EmailHelper.js b/services/web/app/src/Features/Helpers/EmailHelper.js index 2fa4975cb7..c24e68876f 100644 --- a/services/web/app/src/Features/Helpers/EmailHelper.js +++ b/services/web/app/src/Features/Helpers/EmailHelper.js @@ -17,7 +17,7 @@ function parseEmail(email, parseRfcAddress = false) { if (parseRfcAddress) { const result = parseOneAddress(email) - if (!result) { + if (!result?.address) { return null } email = result.address diff --git a/services/web/test/unit/src/HelperFiles/EmailHelperTests.js b/services/web/test/unit/src/HelperFiles/EmailHelperTests.js index 4e8aa6fc6e..762ca60759 100644 --- a/services/web/test/unit/src/HelperFiles/EmailHelperTests.js +++ b/services/web/test/unit/src/HelperFiles/EmailHelperTests.js @@ -29,4 +29,10 @@ describe('EmailHelper', function () { expect(parseEmail(address)).to.equal(null) expect(parseEmail(address, true)).to.equal(null) }) + + it('should return null for a group of addresses', function () { + const address = 'Group name:test1@example.com,test2@example.com;' + expect(parseEmail(address)).to.equal(null) + expect(parseEmail(address, true)).to.equal(null) + }) })