From 28ae23d79e79ed57bd3e3c3f08327b8eec7597a5 Mon Sep 17 00:00:00 2001 From: "michael.buettner%sun.com" Date: Fri, 16 Mar 2007 08:47:44 +0000 Subject: [PATCH] bug #359712 bad handling of attendees (entry corruption) --- .../sun-calendar-event-dialog-attendees.xml | 35 +++++++++++-------- .../wcap/sun-calendar-event-dialog.js | 9 +++-- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml b/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml index ea4534cd6820..408d0df17a70 100644 --- a/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml +++ b/calendar/prototypes/wcap/sun-calendar-event-dialog-attendees.xml @@ -326,7 +326,7 @@ if (aDisableIfOrganizer) { if (aAttendee) { if (this.mOrganizerID && this.mOrganizerID != "") { - if (aAttendee.id == this.mOrganizerID) { + if (aAttendee.id.toLowerCase() == this.mOrganizerID.toLowerCase()) { input.setAttribute("disabled","true"); } } @@ -347,19 +347,24 @@ // construct the display string from common name and/or email address. var inputValue = aAttendee.commonName; + var regexp = new RegExp("^mailto:(.*)", "i"); if(inputValue) { var email = aAttendee.id; if(email && email.length) { - if (email.indexOf("mailto:") == 0) - email = email.split("mailto:")[1] - inputValue += ' <'+email+'>'; + if (regexp.test(email)) { + inputValue += ' <' + RegExp.$1 + '>'; + } else { + inputValue += ' <' + email + '>'; + } } } else { var email = aAttendee.id; if(email && email.length) { - if (email.indexOf("mailto:") == 0) - email = email.split("mailto:")[1] + if (regexp.test(email)) { + inputValue = RegExp.$1; + } else { inputValue = email; + } } } @@ -374,7 +379,7 @@ if (aAttendee) { if (this.mOrganizerID && this.mOrganizerID != "") { - if (aAttendee.id == this.mOrganizerID) { + if (aAttendee.id.toLowerCase() == this.mOrganizerID.toLowerCase()) { icon.setAttribute("class","status-icon"); icon.setAttribute("status",aAttendee.participationStatus); @@ -501,9 +506,9 @@ // to look like an email-address, we prepend the prefix. // this also allows for non-email-addresses. var email = emailAddresses.value[0]; - if (email.indexOf("mailto:") != 0) + if (email.toLowerCase().indexOf("mailto:") != 0) if (email.indexOf("@") >= 0) - email = "mailto:" + email; + email = "MAILTO:" + email; attendee.id = email; } if(names.value.length > 0) { @@ -512,7 +517,7 @@ var addAttendee = true; if (this.mOrganizerID && this.mOrganizerID != "") { - if (attendee.id == this.mOrganizerID) { + if (attendee.id.toLowerCase() == this.mOrganizerID.toLowerCase()) { if (i == 1) { addAttendee = false; } @@ -563,9 +568,9 @@ // to look like an email-address, we prepend the prefix. // this also allows for non-email-addresses. var email = emailAddresses.value[0]; - if (email.indexOf("mailto:") != 0) + if (email.toLowerCase().indexOf("mailto:") != 0) if (email.indexOf("@") >= 0) - email = "mailto:" + email; + email = "MAILTO:" + email; attendee.id = email; } if(names.value.length > 0) { @@ -573,7 +578,7 @@ } if (this.mOrganizerID && this.mOrganizerID != "") { - if (attendee.id == this.mOrganizerID) { + if (attendee.id.toLowerCase() == this.mOrganizerID.toLowerCase()) { return attendee; } } @@ -610,9 +615,9 @@ // to look like an email-address, we prepend the prefix. // this also allows for non-email-addresses. email = emailAddresses.value[0]; - if (email.indexOf("mailto:") != 0) + if (email.toLowerCase().indexOf("mailto:") != 0) if (email.indexOf("@") >= 0) - email = "mailto:" + email; + email = "MAILTO:" + email; } var isdirty = false; diff --git a/calendar/prototypes/wcap/sun-calendar-event-dialog.js b/calendar/prototypes/wcap/sun-calendar-event-dialog.js index 0d50846a2f82..331f18b27db4 100644 --- a/calendar/prototypes/wcap/sun-calendar-event-dialog.js +++ b/calendar/prototypes/wcap/sun-calendar-event-dialog.js @@ -2654,6 +2654,7 @@ function browseDocument() function updateAttendees() { + var regexp = new RegExp("^mailto:(.*)", "i"); var attendeeRow = document.getElementById("attendee-row"); if(!window.attendees || !window.attendees.length) { attendeeRow.setAttribute('collapsed','true'); @@ -2667,9 +2668,11 @@ function updateAttendees() attendeeNames += attendee.commonName; } else if(attendee.id && attendee.id.length) { var email = attendee.id; - if (email.indexOf("mailto:") == 0) - email = email.split("mailto:")[1] - attendeeNames += email; + if (regexp.test(email)) { + attendeeNames += RegExp.$1; + } else { + attendeeNames += email; + } } else { continue; }