From 4c92473d7893d17259c6a74aefd99b0e76fc2d68 Mon Sep 17 00:00:00 2001 From: aceman Date: Sat, 20 Feb 2016 21:33:30 +0100 Subject: [PATCH] Bug 1249873 - Use makeMailboxObject() instead of hardcoded 'name ' strings in displayNameUtils.js. r=jorgk --- mail/base/modules/displayNameUtils.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mail/base/modules/displayNameUtils.js b/mail/base/modules/displayNameUtils.js index df71541495..74e886cea4 100644 --- a/mail/base/modules/displayNameUtils.js +++ b/mail/base/modules/displayNameUtils.js @@ -86,7 +86,9 @@ function FormatDisplayName(aEmailAddress, aHeaderDisplayName, aContext, aCard) // Make sure we have an unambiguous name if there are multiple identities 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 @@ -116,15 +118,16 @@ function FormatDisplayName(aEmailAddress, aHeaderDisplayName, aContext, aCard) function FormatDisplayNameList(aHeaderValue, aContext) { let addresses = MailServices.headerParser.parseDecodedHeader(aHeaderValue); 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) return displayName; // Construct default display. if (addresses[0].email) { - return addresses[0].name ? - addresses[0].name + " <" + addresses[0].email + ">" : - addresses[0].email; + return MailServices.headerParser + .makeMailboxObject(addresses[0].name, + addresses[0].email).toString(); } }