Bug 1249873 - Use makeMailboxObject() instead of hardcoded 'name <email>' strings in displayNameUtils.js. r=jorgk

This commit is contained in:
aceman 2016-02-20 21:33:30 +01:00
Родитель 3b264236f9
Коммит 4c92473d78
1 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -86,7 +86,9 @@ function FormatDisplayName(aEmailAddress, aHeaderDisplayName, aContext, aCard)
// Make sure we have an unambiguous name if there are multiple identities // Make sure we have an unambiguous name if there are multiple identities
if (MailServices.accounts.allIdentities.length > 1) if (MailServices.accounts.allIdentities.length > 1)
displayName += " <" + identity.email + ">"; displayName = MailServices.headerParser
.makeMailboxObject(displayName,
identity.email).toString();
} }
// If we don't have a card, refuse to generate a display name. Places calling // If we don't have a card, refuse to generate a display name. Places calling
@ -116,15 +118,16 @@ function FormatDisplayName(aEmailAddress, aHeaderDisplayName, aContext, aCard)
function FormatDisplayNameList(aHeaderValue, aContext) { function FormatDisplayNameList(aHeaderValue, aContext) {
let addresses = MailServices.headerParser.parseDecodedHeader(aHeaderValue); let addresses = MailServices.headerParser.parseDecodedHeader(aHeaderValue);
if (addresses.length > 0) { if (addresses.length > 0) {
let displayName = FormatDisplayName(addresses[0].email, addresses[0].name, aContext); let displayName = FormatDisplayName(addresses[0].email,
addresses[0].name, aContext);
if (displayName) if (displayName)
return displayName; return displayName;
// Construct default display. // Construct default display.
if (addresses[0].email) { if (addresses[0].email) {
return addresses[0].name ? return MailServices.headerParser
addresses[0].name + " <" + addresses[0].email + ">" : .makeMailboxObject(addresses[0].name,
addresses[0].email; addresses[0].email).toString();
} }
} }