Bug 1229329 - commonName in addAttendee() cannot be updated in all cases;r+a=phillip
authorMakeMyDay <makemyday@gmx-topmail.de>
Sun, 13 Dec 2015 00:01:01 +0100
changeset 26483 459a4f930fe5b6caf80294b1b8ceb4e59c829699
parent 26480 55507ff7483eff625ee53bb64660c33f36f2c68a
child 26484 1423f97e18424f37dc97ca2183b8d7c2f0907dd9
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)
bugs1229329
Bug 1229329 - commonName in addAttendee() cannot be updated in all cases;r+a=phillip
calendar/base/modules/calItipUtils.jsm
calendar/base/src/calItemBase.js
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -577,35 +577,34 @@ cal.itip = {
                 }
             }
         }
 
         let autoResponse = { value: false }; // controls confirm to send email only once
 
         let invitedAttendee = cal.isInvitation(aItem) && cal.getInvitedAttendee(aItem);
         if (invitedAttendee) { // actually is an invitation copy, fix attendee list to send REPLY
+            invitedAttendee = invitedAttendee.clone();
             /* We check if the attendee id matches one of of the
              * userAddresses. If they aren't equal, it means that
              * someone is accepting invitations on behalf of an other user. */
             if (aItem.calendar.aclEntry) {
                 let userAddresses = aItem.calendar.aclEntry.getUserAddresses({});
                 if (userAddresses.length > 0
                     && !cal.attendeeMatchesAddresses(invitedAttendee, userAddresses)) {
-                    invitedAttendee = invitedAttendee.clone();
                     invitedAttendee.setProperty("SENT-BY", "mailto:" + userAddresses[0]);
                 }
             }
 
             if (aItem.organizer) {
                 let origInvitedAttendee = (aOriginalItem && aOriginalItem.getAttendeeById(invitedAttendee.id));
 
                 if (aOpType == Components.interfaces.calIOperationListener.DELETE) {
                     // in case the attendee has just deleted the item, we want to send out a DECLINED REPLY:
                     origInvitedAttendee = invitedAttendee;
-                    invitedAttendee = invitedAttendee.clone();
                     invitedAttendee.participationStatus = "DECLINED";
                 }
 
                 // We want to send a REPLY send if:
                 // - there has been a PARTSTAT change
                 // - in case of an organizer SEQUENCE bump we'd go and reconfirm our PARTSTAT
                 if (!origInvitedAttendee ||
                     (origInvitedAttendee.participationStatus != invitedAttendee.participationStatus) ||
--- a/calendar/base/src/calItemBase.js
+++ b/calendar/base/src/calItemBase.js
@@ -566,20 +566,27 @@ calItemBase.prototype = {
                 this.removeAttendee(exists);
             } else {
                 attendee = null;
             }
         }
         if (attendee) {
             if (attendee.commonName) {
                 // migration code for bug 1209399 to remove leading/training double quotes in
-                attendee.commonName = attendee.commonName
-                                              .replace(/^["]*([^"]*)["]*$/, "$1");
-                if (attendee.commonName.length == 0) {
-                    attendee.commonName = null;
+                let cn = attendee.commonName.replace(/^["]*([^"]*)["]*$/, "$1");
+                if (cn.length == 0) {
+                    cn = null;
+                }
+                if (cn != attendee.commonName) {
+                    if (attendee.isMutable) {
+                        attendee.commonName = cn;
+                    } else {
+                        cal.LOG("Failed to cleanup malformed commonName for immutable attendee " +
+                                attendee.toString() + "\n" + cal.STACK(20));
+                    }
                 }
             }
             this.modify();
             this.mAttendees = this.getAttendees({});
             this.mAttendees.push(attendee);
         }
     },