www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 48851108ea4a67ae788d6c039dec0ad578efd4ea
parent 110d6bac70e5c6c40d0fcca62387a9ea4f209da3
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon, 21 Sep 2009 07:04:30 +0000

enhanced proxy checks (should fix http://forums.zotero.org/discussion/8810/trouble-with-ezproxy-i-think)


Diffstat:
Mchrome/content/zotero/xpcom/proxy.js | 46++++++++++++++++++++++++++++++++++++++--------
1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/chrome/content/zotero/xpcom/proxy.js b/chrome/content/zotero/xpcom/proxy.js @@ -114,14 +114,42 @@ Zotero.Proxies = new function() { if(webNav) { var proxied = Zotero.Proxies.properToProxy(url, true); if(proxied) { - channel.QueryInterface(Components.interfaces.nsIHttpChannel); - // If the referrer is a proxiable host, we already have access - // (e.g., we're on-campus) and shouldn't redirect - if (channel.referrer) { - if (Zotero.Proxies.properToProxy(channel.referrer.spec, true)) { + channel.QueryInterface(Components.interfaces.nsIHttpChannel); + var proxiedURI = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService) + .newURI(proxied, null, null); + if(channel.referrer) { + // If the referrer is a proxiable host, we already have access (e.g., we're + // on-campus) and shouldn't redirect + if(Zotero.Proxies.properToProxy(channel.referrer.spec, true)) { + Zotero.debug("Zotero.Proxies: skipping redirect; referrer was proxiable"); + return; + } + // If the referrer is the same host as we're about to redirect to, we shouldn't + // or we risk a loop + if(channel.referrer.host == proxiedURI.host) { + Zotero.debug("Zotero.Proxies: skipping redirect; redirect URI and referrer have same host"); return; } } + + if(channel.originalURI) { + // If the original URI was a proxied host, we also shouldn't redirect, since any + // links handed out by the proxy should already be proxied + if(Zotero.Proxies.proxyToProper(channel.originalURI.spec, true)) { + Zotero.debug("Zotero.Proxies: skipping redirect; original URI was proxied"); + return; + } + // Finally, if the original URI is the same as the host we're about to redirect + // to, then we also risk a loop + if(channel.originalURI.host == proxiedURI.host) { + Zotero.debug("Zotero.Proxies: skipping redirect; redirect URI and original URI have same host"); + return; + } + } + + // Otherwise, redirect. Note that we save the URI we're redirecting from as the + // referrer, since we can't make a proper redirect webNav.loadURI(proxied, 0, channel.URI, null, null); } } @@ -233,7 +261,8 @@ Zotero.Proxies = new function() { */ const hostBlacklist = [ /google\.com$/, - /wikipedia\.org$/ + /wikipedia\.org$/, + /^[^.]*$/ ]; /** * Regular expression patterns of hosts that should always be proxied, regardless of whether @@ -630,15 +659,16 @@ Zotero.Proxies.Detectors.EZProxy = function(channel) { var properURL = (m[1].toLowerCase() == "qurl" ? unescape(m[2]) : m[2]); var properURI = Zotero.Proxies.Detectors.EZProxy.ios.newURI(properURL, null, null); + var proxy = false; if(channel.URI.host == proxiedURI.host && [channel.URI.port, 80, 443, -1].indexOf(proxiedURI.port) == -1) { // Proxy by port - var proxy = new Zotero.Proxy(); + proxy = new Zotero.Proxy(); proxy.multiHost = false; proxy.scheme = proxiedURI.scheme+"://"+proxiedURI.hostPort+"/%p"; proxy.hosts = [properURI.hostPort]; } else if(proxiedURI.host != channel.URI.host && proxiedURI.hostPort.indexOf(properURI.host) != -1) { // Proxy by host - var proxy = new Zotero.Proxy(); + proxy = new Zotero.Proxy(); proxy.multiHost = proxy.autoAssociate = true; proxy.scheme = proxiedURI.scheme+"://"+proxiedURI.hostPort.replace(properURI.host, "%h")+"/%p"; proxy.hosts = [properURI.hostPort];