Bug 1721946 - Read multiple name values correctly when converting from VCard. r=rnons
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 23 Jul 2021 15:12:45 +1200
changeset 33254 5e78571e7056e2950b353bb5d9b9083803d9ff8a
parent 33253 5df88be32508892635ec569537da7e67143696cb
child 33255 5518f9fe53642a195e3dc2ba8791e0f12a62ea3b
push id19009
push usergeoff@darktrojan.net
push dateFri, 23 Jul 2021 09:55:59 +0000
treeherdercomm-central@24234fc0a9aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnons
bugs1721946
Bug 1721946 - Read multiple name values correctly when converting from VCard. r=rnons Differential Revision: https://phabricator.services.mozilla.com/D120694
mailnews/addrbook/modules/VCardUtils.jsm
mailnews/addrbook/test/unit/test_vCard.js
--- a/mailnews/addrbook/modules/VCardUtils.jsm
+++ b/mailnews/addrbook/modules/VCardUtils.jsm
@@ -419,17 +419,20 @@ function multiTextProperty(abPropNames, 
         abPropNames.map(name => map.get(name) || ""),
       ];
     },
     *toAbCard(value) {
       if (Array.isArray(value)) {
         for (let abPropName of abPropNames) {
           let valuePart = value.shift();
           if (abPropName && valuePart) {
-            yield [abPropName, valuePart];
+            yield [
+              abPropName,
+              Array.isArray(valuePart) ? valuePart.join(" ") : valuePart,
+            ];
           }
         }
       } else if (typeof value == "string") {
         // Only one value was given.
         yield [abPropNames[0], value];
       } else {
         console.warn(`Unexpected value for ${vPropName}: ${value}`);
       }
--- a/mailnews/addrbook/test/unit/test_vCard.js
+++ b/mailnews/addrbook/test/unit/test_vCard.js
@@ -44,23 +44,32 @@ add_task(function testVCardToAbCard() {
   });
 
   // PreferMailFormat
   check("X-MOZILLA-HTML:false", {
     PreferMailFormat: Ci.nsIAbPreferMailFormat.plaintext,
   });
 
   // Name
+  check("N:Last;First", { FirstName: "First", LastName: "Last" });
+  check("N:Last;First;;;", { FirstName: "First", LastName: "Last" });
   check("N:Last;First;Middle;Prefix;Suffix", {
     FirstName: "First",
     LastName: "Last",
     AdditionalNames: "Middle",
     NamePrefix: "Prefix",
     NameSuffix: "Suffix",
   });
+  check("N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.", {
+    FirstName: "John",
+    LastName: "Stevenson",
+    AdditionalNames: "Philip Paul",
+    NamePrefix: "Dr.",
+    NameSuffix: "Jr. M.D. A.C.P.",
+  });
 
   // Address
   check(
     "ADR:PO Box 3.14;Apartment 4;123 Main Street;Any Town;CA;91921-1234;U.S.A.",
     {
       WorkPOBox: "PO Box 3.14",
       WorkAddress2: "Apartment 4",
       WorkAddress: "123 Main Street",