Fix bug 492069 - Lightning corrupts ATTENDEE / ORGANIZER with CN parameter that contains a comma. r=philipp
authorDecathlon <bv1578@gmail.com>
Wed, 18 May 2011 21:12:25 +0200
changeset 7786 ceb7dae0c3118b48320b7cc848a29c4e75b86d3f
parent 7785 e5dbe854dad7e759631216a9a1300aa493459bbf
child 7787 2e0ce86044757ca7e79d11e884ad66a801df6009
push id5979
push usermozilla@kewis.ch
push dateWed, 18 May 2011 19:14:30 +0000
treeherdercomm-central@ceb7dae0c311 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs492069
Fix bug 492069 - Lightning corrupts ATTENDEE / ORGANIZER with CN parameter that contains a comma. r=philipp
calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
calendar/base/content/dialogs/calendar-event-dialog.js
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
@@ -329,16 +329,21 @@
           if (!aAttendee) {
               aAttendee = this.createAttendee();
           }
 
           // construct the display string from common name and/or email address.
           var inputValue = aAttendee.commonName;
           var regexp = new RegExp("^mailto:(.*)", "i");
           if (inputValue && this.mHeaderParser) {
+              // Make the commonName appear in quotes if it
+              // contains a comma or semicolon.
+              if (inputValue.search(/[,;]/) != -1) {
+                  inputValue = '"' + inputValue + '"';
+              }
               var email = aAttendee.id;
               if (email && email.length) {
                   if (regexp.test(email)) {
                       inputValue += ' <' + RegExp.$1 + '>';
                   } else {
                       inputValue += ' <' + email + '>';
                   }
               }
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -2824,17 +2824,18 @@ function updateAttendees() {
         }
 
         var attendeeNames = "";
         var numAttendees = window.attendees.length;
         var regexp = new RegExp("^mailto:(.*)", "i");
         for (var i = 0; i < numAttendees; i++) {
             var attendee = window.attendees[i];
             if (attendee.commonName && attendee.commonName.length) {
-                attendeeNames += attendee.commonName;
+                attendeeNames += (attendee.commonName.search(/[,;]/) != -1) ? '"' + attendee.commonName + '"'
+                                                                            : attendee.commonName;
             } else if (attendee.id && attendee.id.length) {
                 var email = attendee.id;
                 if (regexp.test(email)) {
                     attendeeNames += RegExp.$1;
                 } else {
                     attendeeNames += email;
                 }
             } else {