Bug 1318964 - For an emptry group, like undisclosed-recipients, display group name. r=aceman
authorJorg K <jorgk@jorgk.com>
Mon, 21 Nov 2016 23:25:32 +0100
changeset 20734 3f40fe5e5b2799f9273293f1777f86121b97f027
parent 20733 b11789455e43844c9023262ddc34b992db99b082
child 20735 5b50177b250c806d55d1d5108de5f9da6058b395
push id12553
push usermozilla@jorgk.com
push dateMon, 21 Nov 2016 22:29:00 +0000
treeherdercomm-central@b8ec04edc0e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1318964
Bug 1318964 - For an emptry group, like undisclosed-recipients, display group name. r=aceman
mail/base/content/mailWidgets.xml
mail/base/content/mailWindowOverlay.js
mail/base/content/msgHdrViewOverlay.js
--- a/mail/base/content/mailWidgets.xml
+++ b/mail/base/content/mailWidgets.xml
@@ -607,17 +607,17 @@
       <!-- updateEmailAddressNode: private method used to set properties on an address node -->
       <method name="updateEmailAddressNode">
         <parameter name="aEmailNode"/>
         <parameter name="aAddress"/>
         <body>
           <![CDATA[
             aEmailNode.setAttribute("label", aAddress.fullAddress || aAddress.displayName);
             aEmailNode.removeAttribute("tooltiptext");
-            aEmailNode.setAttribute("emailAddress", aAddress.emailAddress);
+            aEmailNode.setAttribute("emailAddress", aAddress.emailAddress || "");
             aEmailNode.setAttribute("fullAddress", aAddress.fullAddress || "");
             aEmailNode.setAttribute("displayName", aAddress.displayName || "");
 
             // Since the control attribute points to the
             // <mail-multi-emailHeaderField> element rather than the XUL
             // <mail-emailaddress>, screen readers don't know to automagically
             // prepend the label when reading the tag, so we force this.
             // Furthermore, at least on Mac, there is no JS labelElement
@@ -626,17 +626,17 @@
             if ("labelElement" in this) {
                 let ariaLabel = this.labelElement.value + ": " +
                                 aAddress.fullAddress || aAddress.displayName;
                 aEmailNode.setAttribute("aria-label", ariaLabel);
             }
 
             try
             {
-              if ("UpdateEmailNodeDetails" in top)
+              if (("UpdateEmailNodeDetails" in top) && aAddress.emailAddress)
                 UpdateEmailNodeDetails(aAddress.emailAddress, aEmailNode);
             }
             catch(ex)
             {
               dump("UpdateEmailNodeDetails failed: " + ex + "\n");
             }
           ]]>
         </body>
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -1229,27 +1229,16 @@ function IsReplyAllEnabled()
                                     myEmail.toLowerCase()));
 
   // Now, let's get the number of unique addresses.
   let uniqueAddresses = MailServices.headerParser.removeDuplicateAddresses(addresses, "");
   let emailAddresses = {};
   let numAddresses = MailServices.headerParser.parseHeadersWithArray(uniqueAddresses,
                                                                      emailAddresses, {}, {});
 
-  // XXX: This should be handled by the nsIMsgHeaderParser.  See Bug 498480.
-  // Remove addresses that look like email groups, because we don't support
-  // those yet.  (Any address with a : in it will be an empty email group,
-  // or the colon and the groupname would be set as the first name, and not
-  // show up in the address at all.)
-  for (var i in emailAddresses.value)
-  {
-    if (emailAddresses.value[i].includes(":"))
-      numAddresses--;
-  }
-
   // I don't want to count my address in the number of addresses to reply
   // to, since I won't be emailing myself.
   if (imInAddresses)
     numAddresses--;
 
   // ReplyAll is enabled if there is more than 1 person to reply to.
   return numAddresses > 1;
 }
--- a/mail/base/content/msgHdrViewOverlay.js
+++ b/mail/base/content/msgHdrViewOverlay.js
@@ -1233,16 +1233,25 @@ function OutputEmailAddresses(headerEntr
   var numAddresses =  0;
 
   numAddresses = MailServices.headerParser
                              .parseHeadersWithArray(emailAddresses, addresses,
                                                     names, fullNames);
   var index = 0;
   if (headerEntry.useToggle)
     headerEntry.enclosingBox.resetAddressView(); // make sure we start clean
+  if (numAddresses == 0 && emailAddresses.includes(":")) {
+    // No addresses and a colon, so an empty group like "undisclosed-recipients: ;".
+    // Add group name so at least something displays.
+    let address = { displayName: emailAddresses };
+    if (headerEntry.useToggle)
+      headerEntry.enclosingBox.addAddressView(address);
+    else
+      updateEmailAddressNode(headerEntry.enclosingBox.emailAddressNode, address);
+  }
   while (index < numAddresses) {
     // If we want to include short/long toggle views and we have a long view,
     // always add it. If we aren't including a short/long view OR if we are and
     // we haven't parsed enough addresses to reach the cutoff valve yet then add
     // it to the default (short) div.
     let address = {};
     address.emailAddress = addresses.value[index];
     address.fullAddress = fullNames.value[index];
@@ -1256,21 +1265,22 @@ function OutputEmailAddresses(headerEntr
   }
 
   if (headerEntry.useToggle)
     headerEntry.enclosingBox.buildViews();
 }
 
 function updateEmailAddressNode(emailAddressNode, address)
 {
-  emailAddressNode.setAttribute("emailAddress", address.emailAddress);
+  emailAddressNode.setAttribute("emailAddress", address.emailAddress || "");
   emailAddressNode.setAttribute("fullAddress", address.fullAddress || "");
   emailAddressNode.setAttribute("displayName", address.displayName || "");
 
-  UpdateEmailNodeDetails(address.emailAddress, emailAddressNode);
+  if (address.emailAddress)
+    UpdateEmailNodeDetails(address.emailAddress, emailAddressNode);
 }
 
 function UpdateEmailNodeDetails(aEmailAddress, aDocumentNode, aCardDetails) {
   // If we haven't been given specific details, search for a card.
   var cardDetails = aCardDetails || GetCardForEmail(aEmailAddress);
   aDocumentNode.cardDetails = cardDetails;
 
   if (!cardDetails.card) {
@@ -1603,17 +1613,18 @@ function SendMailToNode(addressNode, aEv
                          .createInstance(Components.interfaces.nsIMsgCompFields);
   let params = Components.classes["@mozilla.org/messengercompose/composeparams;1"]
                          .createInstance(Components.interfaces.nsIMsgComposeParams);
 
   fields.newsgroups = addressNode.getAttribute("newsgroup");
   if (addressNode.hasAttribute("fullAddress")) {
     let addresses = MailServices.headerParser.makeFromDisplayAddress(
       addressNode.getAttribute("fullAddress"), {});
-    fields.to = MailServices.headerParser.makeMimeHeader(addresses, 1);
+    if (addresses.length > 0)
+      fields.to = MailServices.headerParser.makeMimeHeader(addresses, 1);
   }
 
   params.type = Components.interfaces.nsIMsgCompType.New;
 
   // If aEvent is passed, check if Shift key was pressed for composition in
   // non-default format (HTML vs. plaintext).
   params.format = (aEvent && aEvent.shiftKey) ?
     Components.interfaces.nsIMsgCompFormat.OppositeOfDefault :