Fix handling of relative URIs

This commit is contained in:
Simon Kornblith 2011-07-10 21:59:19 +00:00
parent dde68a51fe
commit 0b36cc47b9

View File

@ -1331,15 +1331,16 @@ Zotero.Utilities.Translate.prototype._convertURL = function(url) {
} else { } else {
if(protocolRe.test(url)) return url; if(protocolRe.test(url)) return url;
if(url.indexOf(":") !== -1) { // resolve local URL
// don't allow protocol switches var resolved = Components.classes["@mozilla.org/network/io-service;1"].
throw "Invalid URL supplied for HTTP request";
}
// resolve relative URIs
return Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService). getService(Components.interfaces.nsIIOService).
newURI(this._translate.location, "", null).resolve(url); newURI(this._translate.location, "", null).resolve(url);
if(!protocolRe.test(resolved)) {
throw new Error("Invalid URL supplied for HTTP request: "+url);
}
return resolved;
} }
} }