diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index 42089d855a..cde3a905f8 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -8,7 +8,6 @@ Zotero.Sync.Storage = new function () { this.SUCCESS = 1; this.ERROR_NO_URL = -1; - this.ERROR_NO_USERNAME = -2; this.ERROR_NO_PASSWORD = -3; this.ERROR_OFFLINE = -4; this.ERROR_UNREACHABLE = -5; @@ -50,18 +49,8 @@ Zotero.Sync.Storage = new function () { }); } var username = Zotero.Sync.Storage.username; - if (!username) { - var msg = "Zotero storage username not provided"; - Zotero.debug(msg); - throw ({ - message: msg, - name: "Z_ERROR_NO_USERNAME", - filename: "storage.js", - toString: function () { return this.message; } - }); - } var password = Zotero.Sync.Storage.password; - if (!password) { + if (username && !password) { var msg = "Zotero storage password not provided"; Zotero.debug(msg); throw ({ @@ -93,8 +82,10 @@ Zotero.Sync.Storage = new function () { getService(Components.interfaces.nsIIOService); try { var uri = ios.newURI(spec, null, null); - uri.username = username; - uri.password = password; + if (username) { + uri.username = username; + uri.password = password; + } } catch (e) { Zotero.debug(e); @@ -858,6 +849,8 @@ Zotero.Sync.Storage = new function () { var lastSyncDate = new Date(Zotero.Sync.Server.lastLocalSyncTime * 1000); Zotero.Utilities.HTTP.WebDAV.doProp("PROPFIND", uri, xmlstr, function (req) { + Zotero.debug(req.responseText); + var funcName = "Zotero.Sync.Storage.purgeOrphanedStorageFiles()"; // Strip XML declaration and convert to E4X @@ -872,13 +865,14 @@ Zotero.Sync.Storage = new function () { var ios = Components.classes["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService); var href = ios.newURI(href, null, null); - if (href.path != path) { - _error("DAV:href '" + href.path - + "' does not match path in " + funcName); - } href = href.path; } + if (href.indexOf(path) == -1) { + _error("DAV:href '" + href + + "' does not begin with path '" + path + "' in " + funcName); + } + // Skip root URI // // Try URL-encoded as well, in case there's a '~' or similar @@ -1524,10 +1518,6 @@ Zotero.Sync.Storage = new function () { callback(null, Zotero.Sync.Storage.ERROR_NO_URL); return; - case 'Z_ERROR_NO_USERNAME': - callback(null, Zotero.Sync.Storage.ERROR_NO_USERNAME); - return; - case 'Z_ERROR_NO_PASSWORD': callback(null, Zotero.Sync.Storage.ERROR_NO_PASSWORD); return; @@ -1768,10 +1758,6 @@ Zotero.Sync.Storage = new function () { var errorMessage = "Please enter a URL."; break; - case Zotero.Sync.Storage.ERROR_NO_USERNAME: - var errorMessage = "Please enter a username."; - break; - case Zotero.Sync.Storage.ERROR_NO_PASSWORD: var errorMessage = "Please enter a password."; break; diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 31101a644e..380c98393f 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1079,6 +1079,10 @@ Zotero.Utilities.HTTP = new function() { // Prevent certificate/authentication dialogs from popping up xmlhttp.mozBackgroundRequest = true; xmlhttp.open("PUT", uri.spec, true); + // Some servers (e.g., Jungle Disk DAV) return a 200 response code + // with Content-Length: 0, which triggers a "no element found" error + // in Firefox, so we override to text + xmlhttp.overrideMimeType("text/plain"); xmlhttp.onreadystatechange = function() { _stateChange(xmlhttp, callback); }; @@ -1112,6 +1116,9 @@ Zotero.Utilities.HTTP = new function() { // Prevent certificate/authentication dialogs from popping up xmlhttp.mozBackgroundRequest = true; xmlhttp.open("DELETE", uri.spec, true); + // Firefox 3 throws a "no element found" error even with a + // 204 ("No Content") response, so we override to text + xmlhttp.overrideMimeType("text/plain"); xmlhttp.onreadystatechange = function() { _stateChange(xmlhttp, callback); };