diff --git a/chrome/content/zotero/xpcom/cookieSandbox.js b/chrome/content/zotero/xpcom/cookieSandbox.js index 87f34b6a3c..79f34daddf 100755 --- a/chrome/content/zotero/xpcom/cookieSandbox.js +++ b/chrome/content/zotero/xpcom/cookieSandbox.js @@ -221,7 +221,7 @@ Zotero.CookieSandbox.prototype = { */ "getCookiesForURI": function(uri) { var hostParts = Zotero.CookieSandbox.normalizeHost(uri.host).split('.'), - pathParts = Zotero.CookieSandbox.normalizePath(uri.filePath || uri.path).split('/'), + pathParts = Zotero.CookieSandbox.normalizePath(uri.filePath || uri.pathQueryRef).split('/'), cookies = {}, found = false, secure = uri.scheme.toUpperCase() == 'HTTPS'; // Fetch cookies starting from the highest level domain diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index 2a42ab8696..6583f6275d 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -449,7 +449,7 @@ Zotero.File = new function(){ this.download = Zotero.Promise.coroutine(function* (uri, path) { Zotero.debug("Saving " + (uri.spec ? uri.spec : uri) - + " to " + (path.path ? path.path : path)); + + " to " + (path.pathQueryRef ? path.pathQueryRef : path)); var deferred = Zotero.Promise.defer(); NetUtil.asyncFetch(uri, function (is, status, request) { diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index 3404621264..94b513673f 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -134,8 +134,7 @@ Zotero.HTTP = new function() { if (options.username) { options.username = options.username.replace(/%2E/, '.'); options.password = url.password || null; - url = url.clone(); - url.userPass = ''; + url = url.mutate().setUserPass('').finalize(); } url = url.spec; diff --git a/chrome/content/zotero/xpcom/proxy.js b/chrome/content/zotero/xpcom/proxy.js index 3eedd2e70b..85f20ef92f 100644 --- a/chrome/content/zotero/xpcom/proxy.js +++ b/chrome/content/zotero/xpcom/proxy.js @@ -509,11 +509,11 @@ Zotero.Proxy.prototype.toProxy = function(uri) { if(param == "%h") { value = this.dotsToHyphens ? uri.hostPort.replace(/-/g, '.') : uri.hostPort; } else if(param == "%p") { - value = uri.path.substr(1); + value = uri.pathQueryRef.substr(1); } else if(param == "%d") { - value = uri.path.substr(0, uri.path.lastIndexOf("/")); + value = uri.pathQueryRef.substr(0, uri.pathQueryRef.lastIndexOf("/")); } else if(param == "%f") { - value = uri.path.substr(uri.path.lastIndexOf("/")+1) + value = uri.pathQueryRef.substr(uri.pathQueryRef.lastIndexOf("/")+1) } proxyURL = proxyURL.substr(0, this.indices[param])+value+proxyURL.substr(this.indices[param]+2); diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js index a279d96d08..258c94bab8 100644 --- a/chrome/content/zotero/xpcom/quickCopy.js +++ b/chrome/content/zotero/xpcom/quickCopy.js @@ -172,7 +172,7 @@ Zotero.QuickCopy = new function() { // Accessing some properties may throw for URIs that do not support those // parts. E.g. hostPort throws NS_ERROR_FAILURE for about:blank var urlHostPort = nsIURI.hostPort; - var urlPath = nsIURI.path; + var urlPath = nsIURI.pathQueryRef; } catch (e) {} diff --git a/chrome/content/zotero/xpcom/storage/streamListener.js b/chrome/content/zotero/xpcom/storage/streamListener.js index 7e07903824..ce955705a9 100644 --- a/chrome/content/zotero/xpcom/storage/streamListener.js +++ b/chrome/content/zotero/xpcom/storage/streamListener.js @@ -271,6 +271,6 @@ Zotero.Sync.Storage.StreamListener.prototype = { _safeSpec: function (uri) { return uri.scheme + '://' + uri.username + ':********@' - + uri.hostPort + uri.path + + uri.hostPort + uri.pathQueryRef }, }; diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js index 55277b2736..ffbd6d1f97 100644 --- a/chrome/content/zotero/xpcom/storage/webdav.js +++ b/chrome/content/zotero/xpcom/storage/webdav.js @@ -185,32 +185,23 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { throw new this.VerificationError("NO_URL"); } - url = scheme + '://' + url; - var dir = "zotero"; var username = this.username; var password = this.password; - if (!username) { throw new this.VerificationError("NO_USERNAME"); } - if (!password) { throw new this.VerificationError("NO_PASSWORD"); } - var ios = Components.classes["@mozilla.org/network/io-service;1"]. - getService(Components.interfaces.nsIIOService); - var uri = ios.newURI(url, null, null); - uri.username = encodeURIComponent(username); - uri.password = encodeURIComponent(password); - if (!uri.spec.match(/\/$/)) { - uri.spec += "/"; - } - this._parentURI = uri; + url = scheme + '://' + + encodeURIComponent(username) + ':' + encodeURIComponent(password) + '@' + + url + + (url.endsWith('/') ? '' : '/'); - var uri = uri.clone(); - uri.spec += "zotero/"; - this._rootURI = uri; + var io = Services.io; + this._parentURI = io.newURI(url, null, null); + this._rootURI = io.newURI(url + "zotero/", null, null); }, @@ -639,8 +630,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { if (req.status == 207) { // Test if missing files return 404s - let missingFileURI = uri.clone(); - missingFileURI.spec += "nonexistent.prop"; + let missingFileURI = uri.mutate().setSpec(uri.spec + "nonexistent.prop").finalize(); try { req = yield Zotero.HTTP.request( "GET", @@ -663,8 +653,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { } // Test if Zotero directory is writable - let testFileURI = uri.clone(); - testFileURI.spec += "zotero-test-file.prop"; + let testFileURI = uri.mutate().setSpec(uri.spec + "zotero-test-file.prop").finalize(); req = yield Zotero.HTTP.request("PUT", testFileURI, { body: " ", successCodes: [200, 201, 204], @@ -744,7 +733,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { createInstance(Components.interfaces.nsIPromptService); var uri = err.uri; if (uri) { - var spec = uri.scheme + '://' + uri.hostPort + uri.path; + var spec = uri.scheme + '://' + uri.hostPort + uri.pathQueryRef; } var errorTitle, errorMsg; @@ -763,7 +752,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { case 403: errorTitle = Zotero.getString('general.permissionDenied'); - errorMsg = Zotero.getString('sync.storage.error.webdav.permissionDenied', err.channel.URI.path) + errorMsg = Zotero.getString('sync.storage.error.webdav.permissionDenied', err.channel.URI.pathQueryRef) + "\n\n" + Zotero.getString('sync.storage.error.checkFileSyncSettings'); break; @@ -830,7 +819,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { if (e.status == 403) { errorTitle = Zotero.getString('general.permissionDenied'); let rootURI = this.rootURI; - let rootSpec = rootURI.scheme + '://' + rootURI.hostPort + rootURI.path + let rootSpec = rootURI.scheme + '://' + rootURI.hostPort + rootURI.pathQueryRef errorMsg = Zotero.getString('sync.storage.error.permissionDeniedAtAddress') + "\n\n" + rootSpec + "\n\n" + Zotero.getString('sync.storage.error.checkFileSyncSettings'); @@ -965,7 +954,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { Zotero.debug("Purging orphaned storage files"); var uri = this.rootURI; - var path = uri.path; + var path = uri.pathQueryRef; var contentTypeXML = { "Content-Type": "text/xml; charset=utf-8" }; var xmlstr = "" @@ -1014,7 +1003,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { if (href.match(/^https?:\/\//)) { let ios = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); - href = ios.newURI(href, null, null).path; + href = ios.newURI(href, null, null).pathQueryRef; } let decodedHref = decodeURIComponent(href).normalize(); @@ -1307,9 +1296,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { * @return {nsIURI} URI of file on storage server */ _getItemURI: function (item) { - var uri = this.rootURI; - uri.spec = uri.spec + item.key + '.zip'; - return uri; + return this.rootURI.mutate().setSpec(this.rootURI.spec + item.key + '.zip').finalize(); }, @@ -1321,9 +1308,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { * @return {nsIURI} URI of property file on storage server */ _getItemPropertyURI: function (item) { - var uri = this.rootURI; - uri.spec = uri.spec + item.key + '.prop'; - return uri; + return this.rootURI.mutate().setSpec(this.rootURI.spec + item.key + '.prop').finalize(); }, @@ -1337,11 +1322,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { if (!uri.spec.match(/\.zip$/)) { return false; } - var propURI = uri.clone(); - propURI.QueryInterface(Components.interfaces.nsIURL); - propURI.fileName = uri.fileName.replace(/\.zip$/, '.prop'); - propURI.QueryInterface(Components.interfaces.nsIURI); - return propURI; + return uri.mutate().setFilePath(uri.filePath.replace(/\.zip$/, '.prop')).finalize(); }, @@ -1379,10 +1360,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { for (let i = 0 ; i < files.length; i++) { let fileName = files[i]; funcs.push(Zotero.Promise.coroutine(function* () { - var deleteURI = this.rootURI.clone(); - deleteURI.QueryInterface(Components.interfaces.nsIURL); - deleteURI.fileName = fileName; - deleteURI.QueryInterface(Components.interfaces.nsIURI); + var deleteURI = this.rootURI.mutate().setSpec(this.rootURI.spec + fileName).finalize(); try { var req = yield Zotero.HTTP.request( "DELETE", @@ -1411,6 +1389,8 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = { // If an item file URI, get the property URI var deletePropURI = this._getPropertyURIFromItemURI(deleteURI); + // Only nsIURL has fileName + deletePropURI.QueryInterface(Ci.nsIURL); // If we already deleted the prop file, skip it if (!deletePropURI || results.deleted.has(deletePropURI.fileName)) {