Bug 1562158 - Remove xpidl [array] use from nsIMsgHeaderParser. r=jorgk
This commit is contained in:
Родитель
31b6198a05
Коммит
b77a40b9cd
|
@ -1723,11 +1723,10 @@ function SendMailToNode(addressNode, aEvent) {
|
|||
fields.newsgroups = addressNode.getAttribute("newsgroup");
|
||||
if (addressNode.hasAttribute("fullAddress")) {
|
||||
let addresses = MailServices.headerParser.makeFromDisplayAddress(
|
||||
addressNode.getAttribute("fullAddress"),
|
||||
{}
|
||||
addressNode.getAttribute("fullAddress")
|
||||
);
|
||||
if (addresses.length > 0) {
|
||||
fields.to = MailServices.headerParser.makeMimeHeader(addresses, 1);
|
||||
fields.to = MailServices.headerParser.makeMimeHeader([addresses[0]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3534,10 +3534,7 @@ function GenericSendMessage(msgType) {
|
|||
let addresses = MailServices.headerParser.makeFromDisplayAddress(
|
||||
GetMsgIdentityElement().value
|
||||
);
|
||||
msgCompFields.from = MailServices.headerParser.makeMimeHeader(
|
||||
addresses,
|
||||
addresses.length
|
||||
);
|
||||
msgCompFields.from = MailServices.headerParser.makeMimeHeader(addresses);
|
||||
var subject = GetMsgSubjectElement().value;
|
||||
msgCompFields.subject = subject;
|
||||
Attachments2CompFields(msgCompFields);
|
||||
|
|
|
@ -133,7 +133,7 @@ function Recipients2CompFields(msgCompFields) {
|
|||
try {
|
||||
let headerParser = MailServices.headerParser;
|
||||
recipient = headerParser
|
||||
.makeFromDisplayAddress(fieldValue, {})
|
||||
.makeFromDisplayAddress(fieldValue)
|
||||
.map(fullValue =>
|
||||
headerParser.makeMimeAddress(fullValue.name, fullValue.email)
|
||||
)
|
||||
|
|
|
@ -371,7 +371,8 @@ nsresult mime_generate_headers(nsIMsgCompFields *fields,
|
|||
nsCOMPtr<nsIMsgHeaderParser> headerParser(
|
||||
mozilla::services::GetHeaderParser());
|
||||
nsCOMPtr<msgIAddressObject> group;
|
||||
headerParser->MakeGroupObject(undisclosedRecipients, nullptr, 0,
|
||||
nsTArray<RefPtr<msgIAddressObject>> noRecipients;
|
||||
headerParser->MakeGroupObject(undisclosedRecipients, noRecipients,
|
||||
getter_AddRefs(group));
|
||||
recipients.AppendElement(group);
|
||||
finalHeaders->SetAddressingHeader("To", recipients);
|
||||
|
|
|
@ -89,12 +89,9 @@ interface nsIMsgHeaderParser : nsISupports {
|
|||
* of mailbox objects, containing no group objects.
|
||||
* @return An array corresponding to the header description.
|
||||
*/
|
||||
void parseEncodedHeader(in ACString aEncodedHeader,
|
||||
Array<msgIAddressObject> parseEncodedHeader(in ACString aEncodedHeader,
|
||||
[optional] in string aHeaderCharset,
|
||||
[optional] in bool aPreserveGroups,
|
||||
[optional] out unsigned long length,
|
||||
[retval, array, size_is(length)]
|
||||
out msgIAddressObject addresses);
|
||||
[optional] in bool aPreserveGroups);
|
||||
|
||||
/**
|
||||
* Parse an address-based header that has not yet been 2047-decoded and does not
|
||||
|
@ -103,10 +100,7 @@ interface nsIMsgHeaderParser : nsISupports {
|
|||
* @param aEncodedHeader The RFC 2047-encoded header to parse.
|
||||
* @return An array corresponding to the header description.
|
||||
*/
|
||||
void parseEncodedHeaderW(in AString aEncodedHeader,
|
||||
[optional] out unsigned long length,
|
||||
[retval, array, size_is(length)]
|
||||
out msgIAddressObject addresses);
|
||||
Array<msgIAddressObject> parseEncodedHeaderW(in AString aEncodedHeader);
|
||||
|
||||
/**
|
||||
* Parse an address-based header that has been 2047-decoded.
|
||||
|
@ -120,11 +114,8 @@ interface nsIMsgHeaderParser : nsISupports {
|
|||
* of mailbox objects, containing no group objects.
|
||||
* @return An array corresponding to the header description.
|
||||
*/
|
||||
void parseDecodedHeader(in AString aDecodedHeader,
|
||||
[optional] in bool aPreserveGroups,
|
||||
[optional] out unsigned long length,
|
||||
[retval, array, size_is(length)]
|
||||
out msgIAddressObject addresses);
|
||||
Array<msgIAddressObject> parseDecodedHeader(in AString aDecodedHeader,
|
||||
[optional] in bool aPreserveGroups);
|
||||
|
||||
/**
|
||||
* Given an array of addresses, make a MIME header suitable for emission.
|
||||
|
@ -135,12 +126,9 @@ interface nsIMsgHeaderParser : nsISupports {
|
|||
* to maximum line length formats.
|
||||
*
|
||||
* @param aAddresses An array corresponding to the header description.
|
||||
* @param aLength The length of said array of addresses.
|
||||
* @return A string that is suitable for writing in a MIME message.
|
||||
*/
|
||||
AString makeMimeHeader([array, size_is(aLength)]
|
||||
in msgIAddressObject aAddresses,
|
||||
in unsigned long aLength);
|
||||
AString makeMimeHeader(in Array<msgIAddressObject> aAddresses);
|
||||
|
||||
/**
|
||||
* Return the first address in the list in a format suitable for display.
|
||||
|
@ -178,8 +166,7 @@ interface nsIMsgHeaderParser : nsISupports {
|
|||
|
||||
/// Return a structured group object having the given name and members.
|
||||
msgIAddressObject makeGroupObject(in AString aName,
|
||||
[array, size_is(aLength)] in msgIAddressObject aMembers,
|
||||
in unsigned long aLength);
|
||||
in Array<msgIAddressObject> aMembers);
|
||||
|
||||
/**
|
||||
* Return an array of structured mailbox objects for the given display name
|
||||
|
@ -191,9 +178,7 @@ interface nsIMsgHeaderParser : nsISupports {
|
|||
* while the string "webmaster@nowhere.invalid, child@nowhere.invalid" would
|
||||
* produce two address objects.
|
||||
*/
|
||||
void makeFromDisplayAddress(in AString aDisplayAddresses,
|
||||
[optional] out unsigned long count,
|
||||
[retval, array, size_is(count)] out msgIAddressObject addresses);
|
||||
Array<msgIAddressObject> makeFromDisplayAddress(in AString aDisplayAddresses);
|
||||
|
||||
/**
|
||||
* Given a string which contains a list of Header addresses, returns a
|
||||
|
|
|
@ -38,8 +38,9 @@ void MakeMimeAddress(const nsAString &aName, const nsAString &aEmail,
|
|||
|
||||
nsCOMPtr<msgIAddressObject> address;
|
||||
headerParser->MakeMailboxObject(aName, aEmail, getter_AddRefs(address));
|
||||
msgIAddressObject *obj = address;
|
||||
headerParser->MakeMimeHeader(&obj, 1, full);
|
||||
nsTArray<RefPtr<msgIAddressObject>> addresses;
|
||||
addresses.AppendElement(address);
|
||||
headerParser->MakeMimeHeader(addresses, full);
|
||||
}
|
||||
|
||||
void MakeDisplayAddress(const nsAString &aName, const nsAString &aEmail,
|
||||
|
@ -70,16 +71,14 @@ nsCOMArray<msgIAddressObject> DecodedHeader(const nsAString &aHeader) {
|
|||
}
|
||||
nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
|
||||
NS_ENSURE_TRUE(headerParser, retval);
|
||||
msgIAddressObject **addresses = nullptr;
|
||||
uint32_t length;
|
||||
nsresult rv =
|
||||
headerParser->ParseDecodedHeader(aHeader, false, &length, &addresses);
|
||||
nsTArray<RefPtr<msgIAddressObject>> addresses;
|
||||
nsresult rv = headerParser->ParseDecodedHeader(aHeader, false, addresses);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "Javascript jsmime returned an error!");
|
||||
if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
|
||||
// retval.Adopt(addresses, length);
|
||||
retval.Clear();
|
||||
retval.AppendElements(addresses, length);
|
||||
free(addresses);
|
||||
if (NS_SUCCEEDED(rv) && addresses.Length() > 0) {
|
||||
retval.SetCapacity(addresses.Length());
|
||||
for (auto &addr : addresses) {
|
||||
retval.AppendElement(addr);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -92,16 +91,15 @@ nsCOMArray<msgIAddressObject> EncodedHeader(const nsACString &aHeader,
|
|||
}
|
||||
nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
|
||||
NS_ENSURE_TRUE(headerParser, retval);
|
||||
msgIAddressObject **addresses = nullptr;
|
||||
uint32_t length;
|
||||
nsresult rv = headerParser->ParseEncodedHeader(aHeader, aCharset, false,
|
||||
&length, &addresses);
|
||||
nsTArray<RefPtr<msgIAddressObject>> addresses;
|
||||
nsresult rv =
|
||||
headerParser->ParseEncodedHeader(aHeader, aCharset, false, addresses);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
|
||||
if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
|
||||
// retval.Adopt(addresses, length);
|
||||
retval.Clear();
|
||||
retval.AppendElements(addresses, length);
|
||||
free(addresses);
|
||||
if (NS_SUCCEEDED(rv) && addresses.Length() > 0) {
|
||||
retval.SetCapacity(addresses.Length());
|
||||
for (auto &addr : addresses) {
|
||||
retval.AppendElement(addr);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -113,15 +111,14 @@ nsCOMArray<msgIAddressObject> EncodedHeaderW(const nsAString &aHeader) {
|
|||
}
|
||||
nsCOMPtr<nsIMsgHeaderParser> headerParser(services::GetHeaderParser());
|
||||
NS_ENSURE_TRUE(headerParser, retval);
|
||||
msgIAddressObject **addresses = nullptr;
|
||||
uint32_t length;
|
||||
nsresult rv = headerParser->ParseEncodedHeaderW(aHeader, &length, &addresses);
|
||||
nsTArray<RefPtr<msgIAddressObject>> addresses;
|
||||
nsresult rv = headerParser->ParseEncodedHeaderW(aHeader, addresses);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv), "This should never fail!");
|
||||
if (NS_SUCCEEDED(rv) && length > 0 && addresses) {
|
||||
// retval.Adopt(addresses, length);
|
||||
retval.Clear();
|
||||
retval.AppendElements(addresses, length);
|
||||
free(addresses);
|
||||
if (NS_SUCCEEDED(rv) && addresses.Length() > 0) {
|
||||
retval.SetCapacity(addresses.Length());
|
||||
for (auto &addr : addresses) {
|
||||
retval.AppendElement(addr);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -282,16 +282,16 @@ MimeAddressParser.prototype = {
|
|||
classID: Components.ID("96bd8769-2d0e-4440-963d-22b97fb3ba77"),
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIMsgHeaderParser]),
|
||||
|
||||
parseEncodedHeader(aHeader, aCharset, aPreserveGroups, count) {
|
||||
parseEncodedHeader(aHeader, aCharset, aPreserveGroups) {
|
||||
aHeader = aHeader || "";
|
||||
let value = MimeParser.parseHeaderField(
|
||||
aHeader,
|
||||
MimeParser.HEADER_ADDRESS | MimeParser.HEADER_OPTION_ALL_I18N,
|
||||
aCharset
|
||||
);
|
||||
return fixArray(value, aPreserveGroups, count);
|
||||
return fixArray(value, aPreserveGroups);
|
||||
},
|
||||
parseEncodedHeaderW(aHeader, count) {
|
||||
parseEncodedHeaderW(aHeader) {
|
||||
aHeader = aHeader || "";
|
||||
let value = MimeParser.parseHeaderField(
|
||||
aHeader,
|
||||
|
@ -300,15 +300,15 @@ MimeAddressParser.prototype = {
|
|||
MimeParser.HEADER_OPTION_DECODE_2047,
|
||||
undefined
|
||||
);
|
||||
return fixArray(value, false, count);
|
||||
return fixArray(value, false);
|
||||
},
|
||||
parseDecodedHeader(aHeader, aPreserveGroups, count) {
|
||||
parseDecodedHeader(aHeader, aPreserveGroups) {
|
||||
aHeader = aHeader || "";
|
||||
let value = MimeParser.parseHeaderField(aHeader, MimeParser.HEADER_ADDRESS);
|
||||
return fixArray(value, aPreserveGroups, count);
|
||||
return fixArray(value, aPreserveGroups);
|
||||
},
|
||||
|
||||
makeMimeHeader(addresses, length) {
|
||||
makeMimeHeader(addresses) {
|
||||
addresses = fixXpconnectAddresses(addresses);
|
||||
// Don't output any necessary continuations, so make line length as large as
|
||||
// possible first.
|
||||
|
@ -387,7 +387,7 @@ MimeAddressParser.prototype = {
|
|||
return object;
|
||||
},
|
||||
|
||||
makeFromDisplayAddress(aDisplay, count) {
|
||||
makeFromDisplayAddress(aDisplay) {
|
||||
if (aDisplay.includes(";") && !/:.*;/.test(aDisplay)) {
|
||||
// Using semicolons as mailbox separators in against the standard, but
|
||||
// used in the wild by some clients.
|
||||
|
@ -424,9 +424,6 @@ MimeAddressParser.prototype = {
|
|||
output.push(this._makeSingleAddress(addr));
|
||||
}
|
||||
}
|
||||
if (count) {
|
||||
count.value = output.length;
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
|
|
|
@ -113,10 +113,8 @@ function run_test() {
|
|||
// Test - strings
|
||||
|
||||
for (let i = 0; i < checks.length; ++i) {
|
||||
dump("Test " + i + "\n");
|
||||
let addrs = MailServices.headerParser.makeFromDisplayAddress(
|
||||
checks[i].displayString,
|
||||
{}
|
||||
checks[i].displayString
|
||||
);
|
||||
let checkaddrs = checks[i].addresses;
|
||||
Assert.equal(addrs.length, checkaddrs.length);
|
||||
|
|
|
@ -1603,7 +1603,7 @@ function GenericSendMessage( msgType )
|
|||
Recipients2CompFields(msgCompFields);
|
||||
var address = GetMsgIdentityElement().value;
|
||||
address = MailServices.headerParser.makeFromDisplayAddress(address);
|
||||
msgCompFields.from = MailServices.headerParser.makeMimeHeader(address, 1);
|
||||
msgCompFields.from = MailServices.headerParser.makeMimeHeader([address[0]]);
|
||||
var subject = GetMsgSubjectElement().value;
|
||||
msgCompFields.subject = subject;
|
||||
Attachments2CompFields(msgCompFields);
|
||||
|
|
|
@ -118,7 +118,7 @@ function Recipients2CompFields(msgCompFields)
|
|||
try {
|
||||
let headerParser = MailServices.headerParser;
|
||||
recipient =
|
||||
headerParser.makeFromDisplayAddress(fieldValue, {}).map(fullValue =>
|
||||
headerParser.makeFromDisplayAddress(fieldValue).map(fullValue =>
|
||||
headerParser.makeMimeAddress(fullValue.name, fullValue.email))
|
||||
.join(", ");
|
||||
} catch (ex) {recipient = fieldValue;}
|
||||
|
|
|
@ -465,7 +465,7 @@ function SendMailTo(fullAddress, aEvent)
|
|||
|
||||
var headerParser = MailServices.headerParser;
|
||||
var addresses = headerParser.makeFromDisplayAddress(fullAddress);
|
||||
fields.to = headerParser.makeMimeHeader(addresses, 1);
|
||||
fields.to = headerParser.makeMimeHeader([addresses[0]]);
|
||||
params.type = Ci.nsIMsgCompType.New;
|
||||
|
||||
// If aEvent is passed, check if Shift key was pressed for composition in
|
||||
|
|
Загрузка…
Ссылка в новой задаче