Fix bug 674088 - Lightning hammers webdav server with repeated OPTIONS and PROPFIND when incorrectly configured as caldav. r=MakeMyDay
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 22 Jul 2015 20:38:16 +0200
changeset 22661 b54342bc4cc56eb6b6f40573dec6c4288be00403
parent 22660 5747795bcfbd5a7ca82e44a31e9fbf7fb32ed61b
child 22662 18d4427d42034f71b24539482ae0b750aab47f62
push id1434
push usermozilla@kewis.ch
push dateWed, 22 Jul 2015 19:01:53 +0000
treeherdercomm-beta@18d4427d4203 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMakeMyDay
bugs674088
Fix bug 674088 - Lightning hammers webdav server with repeated OPTIONS and PROPFIND when incorrectly configured as caldav. r=MakeMyDay
calendar/providers/caldav/calDavCalendar.js
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -1855,41 +1855,43 @@ calDavCalendar.prototype = {
             if (!resourceTypeXml) {
                 resourceType = kDavResourceTypeNone;
             } else if (caldavXPath(resourceTypeXml[0], "C:calendar")) {
                 resourceType = kDavResourceTypeCalendar;
             } else if (caldavXPath(resourceTypeXml[0], "D:collection")) {
                 resourceType = kDavResourceTypeCollection;
             }
 
-            if (resourceType == kDavResourceTypeNone &&
-                !thisCalendar.mDisabled) {
+            if (resourceType == kDavResourceTypeNone) {
                 cal.LOG("CalDAV: No resource type received, " + thisCalendar.name + " doesn't seem to point to a DAV resource");
                 thisCalendar.completeCheckServerInfo(aChangeLogListener,
                                                      Components.interfaces.calIErrors.DAV_NOT_DAV);
                 return;
             }
 
-            if ((resourceType == kDavResourceTypeCollection) &&
-                !thisCalendar.mDisabled) {
+            if (resourceType == kDavResourceTypeCollection) {
                 cal.LOG("CalDAV: " + thisCalendar.name + " points to a DAV resource, but not a CalDAV calendar");
                 thisCalendar.completeCheckServerInfo(aChangeLogListener,
                                                      Components.interfaces.calIErrors.DAV_DAV_NOT_CALDAV);
                 return;
             }
 
-            // if this calendar was previously offline we want to recover
-            if ((resourceType == kDavResourceTypeCalendar) &&
-                thisCalendar.mDisabled) {
-                thisCalendar.mDisabled = false;
-                thisCalendar.mReadOnly = false;
+            if (resourceType == kDavResourceTypeCalendar) {
+                // If this calendar was previously offline we want to recover
+                if (thisCalendar.mDisabled) {
+                    thisCalendar.mDisabled = false;
+                    thisCalendar.mReadOnly = false;
+                }
+                thisCalendar.setCalHomeSet(true);
+                thisCalendar.checkServerCaps(aChangeLogListener);
             }
 
-            thisCalendar.setCalHomeSet(true);
-            thisCalendar.checkServerCaps(aChangeLogListener);
+            // If we get here something must have gone wrong. Abort with a
+            // general error to avoid an endless loop.
+            thisCalendar.completeCheckServerInfo(aChangeLogListener, Components.results.NS_ERROR_FAILURE);
         };
 
         this.sendHttpRequest(this.makeUri(), queryXml, MIME_TEXT_XML, null, (channel) => {
             channel.setRequestHeader("Depth", "0", false);
             channel.requestMethod = "PROPFIND";
             return streamListener;
         }, () => {
             notifyListener(Components.results.NS_ERROR_NOT_AVAILABLE,