Fix bug 761178 - Malformed URL can cause Lightning to delete complete calendar file (CalDAV). r=philipp

--HG--
extra : rebase_source : d648f25713af8c2533e12f5694e2f664ff8cbfa5
This commit is contained in:
Florian Schlichting 2012-11-29 18:25:15 +01:00
Родитель ec5cf381ad
Коммит 797314826a
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -795,6 +795,16 @@ calDavCalendar.prototype = {
eventUri = this.makeUri(this.mItemInfoCache[aItem.id].locationPath);
}
if (eventUri.path == this.calendarUri.path) {
this.notifyOperationComplete(aListener,
Components.results.NS_ERROR_FAILURE,
Components.interfaces.calIOperationListener.DELETE,
aItem.id,
"eventUri and calendarUri paths are the same, " +
"will not go on to delete entire calendar");
return;
}
var thisCalendar = this;
let delListener = {
@ -936,7 +946,10 @@ calDavCalendar.prototype = {
addTargetCalendarItem : function caldav_addTargetCalendarItem(path,calData,aUri, etag, aListener) {
let parser = Components.classes["@mozilla.org/calendar/ics-parser;1"]
.createInstance(Components.interfaces.calIIcsParser);
let uriPathComponentLength = aUri.path.split("/").length;
// aUri.path may contain double slashes whereas path does not
// this confuses our counting, so remove multiple successive slashes
let strippedUriPath = aUri.path.replace(/\/{2,}/g, "/");
let uriPathComponentLength = strippedUriPath.split("/").length;
try {
parser.parseString(calData);
} catch (e) {