--- a/calendar/base/modules/utils/calEmailUtils.jsm
+++ b/calendar/base/modules/utils/calEmailUtils.jsm
@@ -141,17 +141,17 @@ var calemail = {
* @param {String} aRecipients A comma-seperated list of e-mail addresses
* @return {String} A validated comma-seperated list of e-mail addresses
*/
validateRecipientList: function(aRecipients) {
let compFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(
Ci.nsIMsgCompFields
);
// Resolve the list considering also configured common names
- let members = compFields.splitRecipients(aRecipients, false, {});
+ let members = compFields.splitRecipients(aRecipients, false);
let list = [];
let prefix = "";
for (let member of members) {
if (prefix != "") {
// the previous member had no email address - this happens if a recipients CN
// contains a ',' or ';' (splitRecipients(..) behaves wrongly here and produces an
// additional member with only the first CN part of that recipient and no email
// address while the next has the second part of the CN and the according email
--- a/calendar/base/modules/utils/calItipUtils.jsm
+++ b/calendar/base/modules/utils/calItipUtils.jsm
@@ -477,17 +477,17 @@ var calitip = {
* @param {nsIMsgDBHdr} aMsgHdr The message header to check.
* @return {String} The email address of the intended recipient.
*/
getMessageSender: function(aMsgHdr) {
let author = (aMsgHdr && aMsgHdr.author) || "";
let compFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(
Ci.nsIMsgCompFields
);
- let addresses = compFields.splitRecipients(author, true, {});
+ let addresses = compFields.splitRecipients(author, true);
if (addresses.length != 1) {
cal.LOG("No unique email address for lookup in message.\r\n" + cal.STACK(20));
}
return addresses[0] || null;
},
/**
* Scope: iTIP message receiver
@@ -1259,17 +1259,17 @@ var calitip = {
* @return {calIAttendee[]} Returns an array of matching attendees
*/
getAttendeesBySender: function(aAttendees, aEmailAddress) {
let attendees = [];
// we extract the email address to make it work also for a raw header value
let compFields = Cc["@mozilla.org/messengercompose/composefields;1"].createInstance(
Ci.nsIMsgCompFields
);
- let addresses = compFields.splitRecipients(aEmailAddress, true, {});
+ let addresses = compFields.splitRecipients(aEmailAddress, true);
if (addresses.length == 1) {
let searchFor = cal.email.prependMailTo(addresses[0]);
aAttendees.forEach(aAttendee => {
if ([aAttendee.id, aAttendee.getProperty("SENT-BY")].includes(searchFor)) {
attendees.push(aAttendee);
}
});
} else {
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -3900,18 +3900,17 @@ function updateSendLock() {
*/
function CheckValidEmailAddress(aMsgCompFields) {
let invalidStr;
let recipientCount = 0;
// Check that each of the To, CC, and BCC recipients contains a '@'.
for (let type of ["to", "cc", "bcc"]) {
let recipients = aMsgCompFields.splitRecipients(
aMsgCompFields[type],
- false,
- {}
+ false
);
// MsgCompFields contains only non-empty recipients.
recipientCount += recipients.length;
for (let recipient of recipients) {
if (!isValidAddress(recipient)) {
invalidStr = recipient;
break;
}
@@ -6296,43 +6295,43 @@ function LoadIdentity(startup) {
awRemoveRecipients(msgCompFields, "addr_reply", prevReplyTo);
}
if (newReplyTo != "") {
awAddRecipients(msgCompFields, "addr_reply", newReplyTo);
}
}
let toAddrs = new Set(
- msgCompFields.splitRecipients(msgCompFields.to, true, {})
+ msgCompFields.splitRecipients(msgCompFields.to, true)
);
let ccAddrs = new Set(
- msgCompFields.splitRecipients(msgCompFields.cc, true, {})
+ msgCompFields.splitRecipients(msgCompFields.cc, true)
);
if (newCc != prevCc) {
needToCleanUp = true;
if (prevCc) {
awRemoveRecipients(msgCompFields, "addr_cc", prevCc);
}
if (newCc) {
// Ensure none of the Ccs are already in To.
- let cc2 = msgCompFields.splitRecipients(newCc, true, {});
+ let cc2 = msgCompFields.splitRecipients(newCc, true);
newCc = cc2.filter(x => !toAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_cc", newCc);
}
}
if (newBcc != prevBcc) {
needToCleanUp = true;
if (prevBcc) {
awRemoveRecipients(msgCompFields, "addr_bcc", prevBcc);
}
if (newBcc) {
// Ensure none of the Bccs are already in To or Cc.
- let bcc2 = msgCompFields.splitRecipients(newBcc, true, {});
+ let bcc2 = msgCompFields.splitRecipients(newBcc, true);
let toCcAddrs = new Set([...toAddrs, ...ccAddrs]);
newBcc = bcc2.filter(x => !toCcAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_bcc", newBcc);
}
}
if (needToCleanUp) {
awCleanupRows();
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -198,40 +198,40 @@ function CompFields2Recipients(msgCompFi
let msgTo = msgCompFields.to;
let msgCC = msgCompFields.cc;
let msgBCC = msgCompFields.bcc;
let msgNewsgroups = msgCompFields.newsgroups;
let msgFollowupTo = msgCompFields.followupTo;
let havePrimaryRecipient = false;
if (msgReplyTo) {
awSetInputAndPopupFromArray(
- msgCompFields.splitRecipients(msgReplyTo, false, {}),
+ msgCompFields.splitRecipients(msgReplyTo, false),
"addr_reply",
listbox,
templateNode
);
}
if (msgTo) {
- let rcp = msgCompFields.splitRecipients(msgTo, false, {});
+ let rcp = msgCompFields.splitRecipients(msgTo, false);
if (rcp.length) {
awSetInputAndPopupFromArray(rcp, "addr_to", listbox, templateNode);
havePrimaryRecipient = true;
}
}
if (msgCC) {
awSetInputAndPopupFromArray(
- msgCompFields.splitRecipients(msgCC, false, {}),
+ msgCompFields.splitRecipients(msgCC, false),
"addr_cc",
listbox,
templateNode
);
}
if (msgBCC) {
awSetInputAndPopupFromArray(
- msgCompFields.splitRecipients(msgBCC, false, {}),
+ msgCompFields.splitRecipients(msgBCC, false),
"addr_bcc",
listbox,
templateNode
);
}
if (msgNewsgroups) {
awSetInputAndPopup(
msgNewsgroups,
@@ -354,17 +354,17 @@ function awSetInputAndPopupFromArray(
}
}
function awRemoveRecipients(msgCompFields, recipientType, recipientsList) {
if (!msgCompFields || !recipientsList) {
return;
}
- var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
+ var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
for (var index = 0; index < recipientArray.length; index++) {
for (var row = 1; row <= top.MAX_RECIPIENTS; row++) {
var popup = awGetPopupElement(row);
if (popup.value == recipientType) {
var input = awGetInputElement(row);
if (input.value == recipientArray[index]) {
awSetInputAndPopupValue(input, "", popup, "addr_to", -1);
@@ -383,17 +383,17 @@ function awRemoveRecipients(msgCompField
* @param recipientType Type of recipient, e.g. "addr_to".
* @param recipientList A string of addresses to add.
*/
function awAddRecipients(msgCompFields, recipientType, recipientsList) {
if (!msgCompFields || !recipientsList) {
return;
}
- var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
+ var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
awAddRecipientsArray(recipientType, recipientArray);
}
/**
* Adds a batch of new rows matching recipientType and drops in the array of addresses.
*
* @param aRecipientType Type of recipient, e.g. "addr_to".
* @param aAddressArray An array of recipient addresses (strings) to add.
--- a/mail/components/extensions/parent/ext-mail.js
+++ b/mail/components/extensions/parent/ext-mail.js
@@ -1345,21 +1345,20 @@ function convertMessage(msgHdr, extensio
].createInstance(Ci.nsIMsgCompFields);
let messageObject = {
id: messageTracker.getId(msgHdr),
date: new Date(msgHdr.dateInSeconds * 1000),
author: msgHdr.mime2DecodedAuthor,
recipients: composeFields.splitRecipients(
msgHdr.mime2DecodedRecipients,
- false,
- {}
+ false
),
- ccList: composeFields.splitRecipients(msgHdr.ccList, false, {}),
- bccList: composeFields.splitRecipients(msgHdr.bccList, false, {}),
+ ccList: composeFields.splitRecipients(msgHdr.ccList, false),
+ bccList: composeFields.splitRecipients(msgHdr.bccList, false),
subject: msgHdr.mime2DecodedSubject,
read: msgHdr.isRead,
flagged: msgHdr.isFlagged,
};
if (extension.hasPermission("accountsRead")) {
messageObject.folder = convertFolder(msgHdr.folder, msgHdr.accountKey);
}
let tags = msgHdr.getProperty("keywords");
--- a/mailnews/compose/public/nsIMsgCompFields.idl
+++ b/mailnews/compose/public/nsIMsgCompFields.idl
@@ -72,22 +72,21 @@ interface nsIMsgCompFields : msgIWritabl
void removeAttachments();
/**
* This function will split the recipients into an array.
*
* @param aRecipients The recipients list to split.
* @param aEmailAddressOnly Set to true to drop display names from the results
* array.
- * @param aLength The length of the aResult array.
- * @param aResult An array of the recipients.
+ *
+ * @return An array of the recipients.
*/
- void splitRecipients(in AString aRecipients, in boolean aEmailAddressOnly,
- out unsigned long aLength,
- [array, size_is(aLength), retval] out wstring aResult);
+ Array<AString> splitRecipients(in AString aRecipients,
+ in boolean aEmailAddressOnly);
void ConvertBodyToPlainText();
/**
* Indicates whether we need to check if the current |DocumentCharset|
* can represent all the characters in the message body. It should be
* initialized to true and set to false when 'Send Anyway' is selected
* by a user. (bug 249530)
--- a/mailnews/compose/src/nsMsgCompFields.cpp
+++ b/mailnews/compose/src/nsMsgCompFields.cpp
@@ -514,37 +514,24 @@ NS_IMETHODIMP nsMsgCompFields::RemoveAtt
m_attachments.Clear();
return NS_OK;
}
// This method is called during the creation of a new window.
NS_IMETHODIMP
nsMsgCompFields::SplitRecipients(const nsAString &aRecipients,
- bool aEmailAddressOnly, uint32_t *aLength,
- char16_t ***aResult) {
- NS_ENSURE_ARG_POINTER(aLength);
- NS_ENSURE_ARG_POINTER(aResult);
-
- *aLength = 0;
- *aResult = nullptr;
-
+ bool aEmailAddressOnly,
+ nsTArray<nsString> &aResult) {
nsCOMArray<msgIAddressObject> header(EncodedHeaderW(aRecipients));
- nsTArray<nsString> results;
if (aEmailAddressOnly)
- ExtractEmails(header, results);
+ ExtractEmails(header, aResult);
else
- ExtractDisplayAddresses(header, results);
+ ExtractDisplayAddresses(header, aResult);
- uint32_t count = results.Length();
- char16_t **result = (char16_t **)moz_xmalloc(sizeof(char16_t *) * count);
- for (uint32_t i = 0; i < count; ++i) result[i] = ToNewUnicode(results[i]);
-
- *aResult = result;
- *aLength = count;
return NS_OK;
}
// This method is called during the sending of message from
// nsMsgCompose::CheckAndPopulateRecipients()
nsresult nsMsgCompFields::SplitRecipientsEx(const nsAString &recipients,
nsTArray<nsMsgRecipient> &aResult) {
nsTArray<nsString> names, addresses;
--- a/mailnews/compose/test/unit/test_splitRecipients.js
+++ b/mailnews/compose/test/unit/test_splitRecipients.js
@@ -143,24 +143,21 @@ function run_test() {
"@mozilla.org/messengercompose/composefields;1"
].createInstance(Ci.nsIMsgCompFields);
// As most of SplitRecipients functionality is in the nsIMsgHeaderParser
// functionality, here (at least initially), we're just interested in checking
// the basic argument/return combinations.
for (var part = 0; part < splitRecipientsTests.length; ++part) {
- var count = {};
print("Test: " + splitRecipientsTests[part].recipients);
var result = fields.splitRecipients(
splitRecipientsTests[part].recipients,
- splitRecipientsTests[part].emailAddressOnly,
- count
+ splitRecipientsTests[part].emailAddressOnly
);
- Assert.equal(splitRecipientsTests[part].count, count.value);
Assert.equal(splitRecipientsTests[part].count, result.length);
- for (var item = 0; item < count.value; ++item) {
+ for (var item = 0; item < result.length; ++item) {
Assert.equal(splitRecipientsTests[part].result[item], result[item]);
}
}
}
--- a/suite/mailnews/components/compose/content/MsgComposeCommands.js
+++ b/suite/mailnews/components/compose/content/MsgComposeCommands.js
@@ -2858,40 +2858,40 @@ function LoadIdentity(startup)
{
needToCleanUp = true;
if (prevReplyTo != "")
awRemoveRecipients(msgCompFields, "addr_reply", prevReplyTo);
if (newReplyTo != "")
awAddRecipients(msgCompFields, "addr_reply", newReplyTo);
}
- let toAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.to, true, {}));
- let ccAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.cc, true, {}));
+ let toAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.to, true));
+ let ccAddrs = new Set(msgCompFields.splitRecipients(msgCompFields.cc, true));
if (newCc != prevCc)
{
needToCleanUp = true;
if (prevCc)
awRemoveRecipients(msgCompFields, "addr_cc", prevCc);
if (newCc) {
// Ensure none of the Ccs are already in To.
- let cc2 = msgCompFields.splitRecipients(newCc, true, {});
+ let cc2 = msgCompFields.splitRecipients(newCc, true);
newCc = cc2.filter(x => !toAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_cc", newCc);
}
}
if (newBcc != prevBcc)
{
needToCleanUp = true;
if (prevBcc)
awRemoveRecipients(msgCompFields, "addr_bcc", prevBcc);
if (newBcc) {
// Ensure none of the Bccs are already in To or Cc.
- let bcc2 = msgCompFields.splitRecipients(newBcc, true, {});
+ let bcc2 = msgCompFields.splitRecipients(newBcc, true);
let toCcAddrs = new Set([...toAddrs, ...ccAddrs]);
newBcc = bcc2.filter(x => !toCcAddrs.has(x)).join(", ");
awAddRecipients(msgCompFields, "addr_bcc", newBcc);
}
}
if (needToCleanUp)
awCleanupRows();
--- a/suite/mailnews/components/compose/content/addressingWidgetOverlay.js
+++ b/suite/mailnews/components/compose/content/addressingWidgetOverlay.js
@@ -171,32 +171,32 @@ function CompFields2Recipients(msgCompFi
var msgReplyTo = msgCompFields.replyTo;
var msgTo = msgCompFields.to;
var msgCC = msgCompFields.cc;
var msgBCC = msgCompFields.bcc;
var msgNewsgroups = msgCompFields.newsgroups;
var msgFollowupTo = msgCompFields.followupTo;
var havePrimaryRecipient = false;
if(msgReplyTo)
- awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgReplyTo, false, {}),
+ awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgReplyTo, false),
"addr_reply", newListBoxNode, templateNode);
if(msgTo)
{
- var rcp = msgCompFields.splitRecipients(msgTo, false, {});
+ var rcp = msgCompFields.splitRecipients(msgTo, false);
if (rcp.length)
{
awSetInputAndPopupFromArray(rcp, "addr_to", newListBoxNode, templateNode);
havePrimaryRecipient = true;
}
}
if(msgCC)
- awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgCC, false, {}),
+ awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgCC, false),
"addr_cc", newListBoxNode, templateNode);
if(msgBCC)
- awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgBCC, false, {}),
+ awSetInputAndPopupFromArray(msgCompFields.splitRecipients(msgBCC, false),
"addr_bcc", newListBoxNode, templateNode);
if(msgNewsgroups)
{
awSetInputAndPopup(msgNewsgroups, "addr_newsgroups", newListBoxNode, templateNode);
havePrimaryRecipient = true;
}
if(msgFollowupTo)
awSetInputAndPopup(msgFollowupTo, "addr_followup", newListBoxNode, templateNode);
@@ -271,17 +271,17 @@ function awSetInputAndPopupFromArray(inp
}
}
function awRemoveRecipients(msgCompFields, recipientType, recipientsList)
{
if (!msgCompFields)
return;
- var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
+ var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
for (var index = 0; index < recipientArray.length; index++)
for (var row = 1; row <= top.MAX_RECIPIENTS; row ++)
{
var popup = awGetPopupElement(row);
if (popup.selectedItem.getAttribute("value") == recipientType)
{
var input = awGetInputElement(row);
@@ -294,17 +294,17 @@ function awRemoveRecipients(msgCompField
}
}
function awAddRecipients(msgCompFields, recipientType, recipientsList)
{
if (!msgCompFields)
return;
- var recipientArray = msgCompFields.splitRecipients(recipientsList, false, {});
+ var recipientArray = msgCompFields.splitRecipients(recipientsList, false);
for (var index = 0; index < recipientArray.length; index++)
awAddRecipient(recipientType, recipientArray[index]);
}
// this was broken out of awAddRecipients so it can be re-used...adds a new row matching recipientType and
// drops in the single address.
function awAddRecipient(recipientType, address)