From 4069158178a6a24ecabacc54cb0257cb22e67eaf Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 22 Nov 2018 10:17:09 -0500 Subject: [PATCH] (js) Fix handling of duplicate recipients Fixes #4597 --- NEWS | 1 + .../js/Mailer/MessageEditorController.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 465b6e083..9fc0d65ce 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Enhancements Bug fixes - [sogo-tool] fixed "manage-acl unsubscribe" command (#4591) - [web] fixed handling of collapsed/expanded mail accounts (#4541) + - [web] fixed handling of duplicate recipients (#4597) 4.0.4 (2018-10-23) ------------------ diff --git a/UI/WebServerResources/js/Mailer/MessageEditorController.js b/UI/WebServerResources/js/Mailer/MessageEditorController.js index 1ea00ae1b..af624d843 100644 --- a/UI/WebServerResources/js/Mailer/MessageEditorController.js +++ b/UI/WebServerResources/js/Mailer/MessageEditorController.js @@ -298,7 +298,8 @@ contact.charCodeAt(i) == 32 || // space contact.charCodeAt(i) == 44 || // , contact.charCodeAt(i) == 59) && // ; - emailRE.test(address)) { + emailRE.test(address) && + recipients.indexOf(address) < 0) { recipients.push(address); address = ''; } @@ -306,8 +307,9 @@ address += contact.charAt(i); } } - if (address) + if (address && recipients.indexOf(address) < 0) recipients.push(address); + return null; } @@ -315,7 +317,7 @@ // If the list's members were already fetch, use them if (angular.isDefined(contact.refs) && contact.refs.length) { _.forEach(contact.refs, function(ref) { - if (ref.email.length) + if (ref.email.length && recipients.indexOf(ref.$shortFormat()) < 0) recipients.push(ref.$shortFormat()); }); } @@ -323,7 +325,7 @@ list = Card.$find(contact.container, contact.c_name); list.$id().then(function(listId) { _.forEach(list.refs, function(ref) { - if (ref.email.length) + if (ref.email.length && recipients.indexOf(ref.$shortFormat()) < 0) recipients.push(ref.$shortFormat()); }); });