Fx60: nsIURI changes
- nsIURI is now immutable, so it's necessary to use nsIURIMutator via mutate() to change it - .path is replaced with .pathQueryRef - Only nsIURL has .fileName
This commit is contained in:
parent
fe30a11bde
commit
61e976bd3a
7 changed files with 28 additions and 49 deletions
|
@ -221,7 +221,7 @@ Zotero.CookieSandbox.prototype = {
|
||||||
*/
|
*/
|
||||||
"getCookiesForURI": function(uri) {
|
"getCookiesForURI": function(uri) {
|
||||||
var hostParts = Zotero.CookieSandbox.normalizeHost(uri.host).split('.'),
|
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';
|
cookies = {}, found = false, secure = uri.scheme.toUpperCase() == 'HTTPS';
|
||||||
|
|
||||||
// Fetch cookies starting from the highest level domain
|
// Fetch cookies starting from the highest level domain
|
||||||
|
|
|
@ -449,7 +449,7 @@ Zotero.File = new function(){
|
||||||
|
|
||||||
this.download = Zotero.Promise.coroutine(function* (uri, path) {
|
this.download = Zotero.Promise.coroutine(function* (uri, path) {
|
||||||
Zotero.debug("Saving " + (uri.spec ? uri.spec : uri)
|
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();
|
var deferred = Zotero.Promise.defer();
|
||||||
NetUtil.asyncFetch(uri, function (is, status, request) {
|
NetUtil.asyncFetch(uri, function (is, status, request) {
|
||||||
|
|
|
@ -134,8 +134,7 @@ Zotero.HTTP = new function() {
|
||||||
if (options.username) {
|
if (options.username) {
|
||||||
options.username = options.username.replace(/%2E/, '.');
|
options.username = options.username.replace(/%2E/, '.');
|
||||||
options.password = url.password || null;
|
options.password = url.password || null;
|
||||||
url = url.clone();
|
url = url.mutate().setUserPass('').finalize();
|
||||||
url.userPass = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url = url.spec;
|
url = url.spec;
|
||||||
|
|
|
@ -509,11 +509,11 @@ Zotero.Proxy.prototype.toProxy = function(uri) {
|
||||||
if(param == "%h") {
|
if(param == "%h") {
|
||||||
value = this.dotsToHyphens ? uri.hostPort.replace(/-/g, '.') : uri.hostPort;
|
value = this.dotsToHyphens ? uri.hostPort.replace(/-/g, '.') : uri.hostPort;
|
||||||
} else if(param == "%p") {
|
} else if(param == "%p") {
|
||||||
value = uri.path.substr(1);
|
value = uri.pathQueryRef.substr(1);
|
||||||
} else if(param == "%d") {
|
} else if(param == "%d") {
|
||||||
value = uri.path.substr(0, uri.path.lastIndexOf("/"));
|
value = uri.pathQueryRef.substr(0, uri.pathQueryRef.lastIndexOf("/"));
|
||||||
} else if(param == "%f") {
|
} 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);
|
proxyURL = proxyURL.substr(0, this.indices[param])+value+proxyURL.substr(this.indices[param]+2);
|
||||||
|
|
|
@ -172,7 +172,7 @@ Zotero.QuickCopy = new function() {
|
||||||
// Accessing some properties may throw for URIs that do not support those
|
// Accessing some properties may throw for URIs that do not support those
|
||||||
// parts. E.g. hostPort throws NS_ERROR_FAILURE for about:blank
|
// parts. E.g. hostPort throws NS_ERROR_FAILURE for about:blank
|
||||||
var urlHostPort = nsIURI.hostPort;
|
var urlHostPort = nsIURI.hostPort;
|
||||||
var urlPath = nsIURI.path;
|
var urlPath = nsIURI.pathQueryRef;
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
|
|
|
@ -271,6 +271,6 @@ Zotero.Sync.Storage.StreamListener.prototype = {
|
||||||
|
|
||||||
_safeSpec: function (uri) {
|
_safeSpec: function (uri) {
|
||||||
return uri.scheme + '://' + uri.username + ':********@'
|
return uri.scheme + '://' + uri.username + ':********@'
|
||||||
+ uri.hostPort + uri.path
|
+ uri.hostPort + uri.pathQueryRef
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -185,32 +185,23 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
throw new this.VerificationError("NO_URL");
|
throw new this.VerificationError("NO_URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
url = scheme + '://' + url;
|
|
||||||
var dir = "zotero";
|
|
||||||
var username = this.username;
|
var username = this.username;
|
||||||
var password = this.password;
|
var password = this.password;
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
throw new this.VerificationError("NO_USERNAME");
|
throw new this.VerificationError("NO_USERNAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!password) {
|
if (!password) {
|
||||||
throw new this.VerificationError("NO_PASSWORD");
|
throw new this.VerificationError("NO_PASSWORD");
|
||||||
}
|
}
|
||||||
|
|
||||||
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
url = scheme + '://'
|
||||||
getService(Components.interfaces.nsIIOService);
|
+ encodeURIComponent(username) + ':' + encodeURIComponent(password) + '@'
|
||||||
var uri = ios.newURI(url, null, null);
|
+ url
|
||||||
uri.username = encodeURIComponent(username);
|
+ (url.endsWith('/') ? '' : '/');
|
||||||
uri.password = encodeURIComponent(password);
|
|
||||||
if (!uri.spec.match(/\/$/)) {
|
|
||||||
uri.spec += "/";
|
|
||||||
}
|
|
||||||
this._parentURI = uri;
|
|
||||||
|
|
||||||
var uri = uri.clone();
|
var io = Services.io;
|
||||||
uri.spec += "zotero/";
|
this._parentURI = io.newURI(url, null, null);
|
||||||
this._rootURI = uri;
|
this._rootURI = io.newURI(url + "zotero/", null, null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -639,8 +630,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
|
|
||||||
if (req.status == 207) {
|
if (req.status == 207) {
|
||||||
// Test if missing files return 404s
|
// Test if missing files return 404s
|
||||||
let missingFileURI = uri.clone();
|
let missingFileURI = uri.mutate().setSpec(uri.spec + "nonexistent.prop").finalize();
|
||||||
missingFileURI.spec += "nonexistent.prop";
|
|
||||||
try {
|
try {
|
||||||
req = yield Zotero.HTTP.request(
|
req = yield Zotero.HTTP.request(
|
||||||
"GET",
|
"GET",
|
||||||
|
@ -663,8 +653,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if Zotero directory is writable
|
// Test if Zotero directory is writable
|
||||||
let testFileURI = uri.clone();
|
let testFileURI = uri.mutate().setSpec(uri.spec + "zotero-test-file.prop").finalize();
|
||||||
testFileURI.spec += "zotero-test-file.prop";
|
|
||||||
req = yield Zotero.HTTP.request("PUT", testFileURI, {
|
req = yield Zotero.HTTP.request("PUT", testFileURI, {
|
||||||
body: " ",
|
body: " ",
|
||||||
successCodes: [200, 201, 204],
|
successCodes: [200, 201, 204],
|
||||||
|
@ -744,7 +733,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
createInstance(Components.interfaces.nsIPromptService);
|
createInstance(Components.interfaces.nsIPromptService);
|
||||||
var uri = err.uri;
|
var uri = err.uri;
|
||||||
if (uri) {
|
if (uri) {
|
||||||
var spec = uri.scheme + '://' + uri.hostPort + uri.path;
|
var spec = uri.scheme + '://' + uri.hostPort + uri.pathQueryRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
var errorTitle, errorMsg;
|
var errorTitle, errorMsg;
|
||||||
|
@ -763,7 +752,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
|
|
||||||
case 403:
|
case 403:
|
||||||
errorTitle = Zotero.getString('general.permissionDenied');
|
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');
|
+ "\n\n" + Zotero.getString('sync.storage.error.checkFileSyncSettings');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -830,7 +819,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
if (e.status == 403) {
|
if (e.status == 403) {
|
||||||
errorTitle = Zotero.getString('general.permissionDenied');
|
errorTitle = Zotero.getString('general.permissionDenied');
|
||||||
let rootURI = this.rootURI;
|
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')
|
errorMsg = Zotero.getString('sync.storage.error.permissionDeniedAtAddress')
|
||||||
+ "\n\n" + rootSpec + "\n\n"
|
+ "\n\n" + rootSpec + "\n\n"
|
||||||
+ Zotero.getString('sync.storage.error.checkFileSyncSettings');
|
+ Zotero.getString('sync.storage.error.checkFileSyncSettings');
|
||||||
|
@ -965,7 +954,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
Zotero.debug("Purging orphaned storage files");
|
Zotero.debug("Purging orphaned storage files");
|
||||||
|
|
||||||
var uri = this.rootURI;
|
var uri = this.rootURI;
|
||||||
var path = uri.path;
|
var path = uri.pathQueryRef;
|
||||||
|
|
||||||
var contentTypeXML = { "Content-Type": "text/xml; charset=utf-8" };
|
var contentTypeXML = { "Content-Type": "text/xml; charset=utf-8" };
|
||||||
var xmlstr = "<propfind xmlns='DAV:'><prop>"
|
var xmlstr = "<propfind xmlns='DAV:'><prop>"
|
||||||
|
@ -1014,7 +1003,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
if (href.match(/^https?:\/\//)) {
|
if (href.match(/^https?:\/\//)) {
|
||||||
let ios = Components.classes["@mozilla.org/network/io-service;1"]
|
let ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
.getService(Components.interfaces.nsIIOService);
|
.getService(Components.interfaces.nsIIOService);
|
||||||
href = ios.newURI(href, null, null).path;
|
href = ios.newURI(href, null, null).pathQueryRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
let decodedHref = decodeURIComponent(href).normalize();
|
let decodedHref = decodeURIComponent(href).normalize();
|
||||||
|
@ -1307,9 +1296,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
* @return {nsIURI} URI of file on storage server
|
* @return {nsIURI} URI of file on storage server
|
||||||
*/
|
*/
|
||||||
_getItemURI: function (item) {
|
_getItemURI: function (item) {
|
||||||
var uri = this.rootURI;
|
return this.rootURI.mutate().setSpec(this.rootURI.spec + item.key + '.zip').finalize();
|
||||||
uri.spec = uri.spec + item.key + '.zip';
|
|
||||||
return uri;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -1321,9 +1308,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
* @return {nsIURI} URI of property file on storage server
|
* @return {nsIURI} URI of property file on storage server
|
||||||
*/
|
*/
|
||||||
_getItemPropertyURI: function (item) {
|
_getItemPropertyURI: function (item) {
|
||||||
var uri = this.rootURI;
|
return this.rootURI.mutate().setSpec(this.rootURI.spec + item.key + '.prop').finalize();
|
||||||
uri.spec = uri.spec + item.key + '.prop';
|
|
||||||
return uri;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -1337,11 +1322,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
if (!uri.spec.match(/\.zip$/)) {
|
if (!uri.spec.match(/\.zip$/)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var propURI = uri.clone();
|
return uri.mutate().setFilePath(uri.filePath.replace(/\.zip$/, '.prop')).finalize();
|
||||||
propURI.QueryInterface(Components.interfaces.nsIURL);
|
|
||||||
propURI.fileName = uri.fileName.replace(/\.zip$/, '.prop');
|
|
||||||
propURI.QueryInterface(Components.interfaces.nsIURI);
|
|
||||||
return propURI;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -1379,10 +1360,7 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
for (let i = 0 ; i < files.length; i++) {
|
for (let i = 0 ; i < files.length; i++) {
|
||||||
let fileName = files[i];
|
let fileName = files[i];
|
||||||
funcs.push(Zotero.Promise.coroutine(function* () {
|
funcs.push(Zotero.Promise.coroutine(function* () {
|
||||||
var deleteURI = this.rootURI.clone();
|
var deleteURI = this.rootURI.mutate().setSpec(this.rootURI.spec + fileName).finalize();
|
||||||
deleteURI.QueryInterface(Components.interfaces.nsIURL);
|
|
||||||
deleteURI.fileName = fileName;
|
|
||||||
deleteURI.QueryInterface(Components.interfaces.nsIURI);
|
|
||||||
try {
|
try {
|
||||||
var req = yield Zotero.HTTP.request(
|
var req = yield Zotero.HTTP.request(
|
||||||
"DELETE",
|
"DELETE",
|
||||||
|
@ -1411,6 +1389,8 @@ Zotero.Sync.Storage.Mode.WebDAV.prototype = {
|
||||||
|
|
||||||
// If an item file URI, get the property URI
|
// If an item file URI, get the property URI
|
||||||
var deletePropURI = this._getPropertyURIFromItemURI(deleteURI);
|
var deletePropURI = this._getPropertyURIFromItemURI(deleteURI);
|
||||||
|
// Only nsIURL has fileName
|
||||||
|
deletePropURI.QueryInterface(Ci.nsIURL);
|
||||||
|
|
||||||
// If we already deleted the prop file, skip it
|
// If we already deleted the prop file, skip it
|
||||||
if (!deletePropURI || results.deleted.has(deletePropURI.fileName)) {
|
if (!deletePropURI || results.deleted.has(deletePropURI.fileName)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue