Merge pull request #11008 from overleaf/msm-fix-email-helper-group

[web] Prevent NPE parsing RFC5322 email groups

GitOrigin-RevId: 57fa7dc523b94c44afdd45a790ff6c3e62e45214
This commit is contained in:
Alf Eaton 2023-01-10 10:36:22 +00:00 committed by Copybot
parent 84f3d52f3b
commit 62b727fb61
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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)
})
})