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:13 +0100
changeset 22214 9abccdd1e73ea36675b55c7eefef81f4e87e4ed5
parent 22213 d7bccd1f9080fde9d300ac0f14855dbe34620c24
child 22215 b88229610b41ce2f7d8abff4f1e91646191aff76
push id71
push usermakemyday@gmx-topmail.de
push dateSat, 12 Dec 2015 23:04:39 +0000
treeherdercomm-esr38@9abccdd1e73e [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
@@ -575,35 +575,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);
         }
     },