Bug 1197320 - Free/Busy information of CalDAV calendar is no longer displayed after latest Lightning Calendar's update (v4.0.2). r+a=philipp
authorMakeMyDay <makemyday@gmx-topmail.de>
Sat, 05 Sep 2015 23:21:12 +0200
changeset 26288 e7b0fc9b04afe301afd8bd06abe4e15c3c3372d6
parent 26287 6f8c6141448ae7a40a3d7d2ea466c833fe1160ca
child 26289 a0c43110aef7f954d348021d38af41490a5ca6d2
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)
bugs1197320
Bug 1197320 - Free/Busy information of CalDAV calendar is no longer displayed after latest Lightning Calendar's update (v4.0.2). r+a=philipp
calendar/base/modules/calItipUtils.jsm
calendar/base/modules/calUtils.jsm
calendar/test/unit/test_calutils.js
calendar/test/unit/xpcshell-shared.ini
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -364,26 +364,26 @@ cal.itip = {
                 let identity = identities.queryElementAt(i, Components.interfaces.nsIMsgIdentity);
                 emailMap[identity.email.toLowerCase()] = true;
             }
         }
 
         // First check the recipient list
         let toList = MailServices.headerParser.makeFromDisplayAddress(aMsgHdr.recipients);
         for (let recipient of toList) {
-            if (recipient.name.toLowerCase() in emailMap) {
+            if (recipient.email.toLowerCase() in emailMap) {
                 // Return the first found recipient
                 return recipient;
             }
         }
 
         // Maybe we are in the CC list?
         let ccList = MailServices.headerParser.makeFromDisplayAddress(aMsgHdr.ccList);
         for (let recipient of ccList) {
-            if (recipient.name.toLowerCase() in emailMap) {
+            if (recipient.email.toLowerCase() in emailMap) {
                 // Return the first found recipient
                 return recipient;
             }
         }
 
         // Hrmpf. Looks like delegation or maybe Bcc.
         return null;
     },
--- a/calendar/base/modules/calUtils.jsm
+++ b/calendar/base/modules/calUtils.jsm
@@ -289,17 +289,17 @@ let cal = {
 
     /**
      * Prepends a mailto: prefix to an email address like string
      *
      * @param  {string}        the string to prepend the prefix if not already there
      * @return {string}        the string with prefix
      */
     prependMailTo: function(aId) {
-        return (!aId.search(/^MAILTO:/i) && aId.includes("@")) ? "MAILTO:" + aId : aId;
+        return aId.replace(/^(?:mailto:)?(.*)@/i, "mailto:$1@");
     },
 
     /**
      * Removes an existing mailto: prefix from an attendee id
      *
      * @param  {string}       the string to remove the prefix from if any
      * @return {string}       the string without prefix
      */
new file mode 100644
--- /dev/null
+++ b/calendar/test/unit/test_calutils.js
@@ -0,0 +1,32 @@
+/* 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://calendar/modules/calUtils.jsm");
+
+function run_test() {
+    removeMailTo_test();
+    prependMailTo_test();
+}
+
+// tests for calUtils.jsm
+
+function removeMailTo_test() {
+    let data = [{input: "mailto:first.last@example.net", expected: "first.last@example.net"},
+                {input: "MAILTO:first.last@example.net", expected: "first.last@example.net"},
+                {input: "first.last@example.net", expected: "first.last@example.net"},
+                {input: "first.last.example.net", expected: "first.last.example.net"}];
+    for (let test of data) {
+        equal(cal.removeMailTo(test.input), test.expected)
+    }
+};
+
+function prependMailTo_test() {
+    let data = [{input: "mailto:first.last@example.net", expected: "mailto:first.last@example.net"},
+                {input: "MAILTO:first.last@example.net", expected: "mailto:first.last@example.net"},
+                {input: "first.last@example.net", expected: "mailto:first.last@example.net"},
+                {input: "first.last.example.net", expected: "first.last.example.net"}];
+    for (let test of data) {
+        equal(cal.prependMailTo(test.input), test.expected)
+    }
+};
--- a/calendar/test/unit/xpcshell-shared.ini
+++ b/calendar/test/unit/xpcshell-shared.ini
@@ -10,16 +10,17 @@
 [test_bug485571.js]
 [test_bug486186.js]
 [test_bug494140.js]
 [test_bug523860.js]
 [test_bug653924.js]
 [test_bug668222.js]
 [test_bug759324.js]
 [test_calmgr.js]
+[test_calutils.js]
 [test_datetime.js]
 [test_datetime_before_1970.js]
 [test_deleted_items.js]
 [test_duration.js]
 [test_extract.js]
 [test_freebusy.js]
 [test_freebusy_service.js]
 [test_gdata_provider.js]