Bug 1071476 - Comma in recipient name splits the recipient name to multiple fields in compose window r=IanN sr=Mnyromyr
authorPhilip Chee <philip.chee@gmail.com>
Sun, 01 Feb 2015 01:12:35 +0800
changeset 25708 f471c3bd3c47ff9208535f764025731d9c32d5e6
parent 25707 e8b1aa4336226be76486cba40a5900d083a45455
child 25709 79513f6e331d46a3be03e8e20ffd035086bd1215
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, Mnyromyr
bugs1071476
Bug 1071476 - Comma in recipient name splits the recipient name to multiple fields in compose window r=IanN sr=Mnyromyr a=IanN comm-aurora, comm-beta, comm-release CLOSED TREE
suite/mailnews/compose/addressingWidgetOverlay.js
--- a/suite/mailnews/compose/addressingWidgetOverlay.js
+++ b/suite/mailnews/compose/addressingWidgetOverlay.js
@@ -1,12 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+Components.utils.import("resource:///modules/mailServices.js");
+
 top.MAX_RECIPIENTS = 1; /* for the initial listitem created in the XUL */
 
 var inputElementType = "";
 var selectElementType = "";
 var selectElementIndexTable = null;
 
 var gNumberOfCols = 0;
 
@@ -979,31 +981,29 @@ function awRecipientInputCommand(event, 
 
 var gAutomatedAutoCompleteListener = null;
 
 function parseAndAddAddresses(addressText, recipientType)
 {
   // strip any leading >> characters inserted by the autocomplete widget
   var strippedAddresses = addressText.replace(/.* >> /, "");
 
-  var hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser);
-  var addresses = {};
-  var names = {};
-  var fullNames = {};
-  var numAddresses = hdrParser.parseHeadersWithArray(strippedAddresses, addresses, names, fullNames);
+  var addresses = MailServices.headerParser
+                              .makeFromDisplayAddress(strippedAddresses);
 
-  if (numAddresses > 0)
+  if (addresses.length)
   {
     // we need to set up our own autocomplete session and search for results
 
     setupAutocomplete(); // be safe, make sure we are setup
     if (!gAutomatedAutoCompleteListener)
       gAutomatedAutoCompleteListener = new AutomatedAutoCompleteHandler();
 
-    gAutomatedAutoCompleteListener.init(fullNames.value, numAddresses, recipientType);
+    gAutomatedAutoCompleteListener.init(addresses.map(addr => addr.toString()),
+                                        addresses.length, recipientType);
   }
 }
 
 function AutomatedAutoCompleteHandler()
 {
 }
 
 // state driven self contained object which will autocomplete a block of addresses without any UI.