зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1255474 - Cut off path from URLs passed to PAC scripts. r=mcmanus
This commit is contained in:
Родитель
86d3aebd18
Коммит
9df1623b92
|
@ -1986,6 +1986,8 @@ pref("network.cookie.lifetime.days", 90); // Ignored unless network.cooki
|
|||
|
||||
// The PAC file to load. Ignored unless network.proxy.type is 2.
|
||||
pref("network.proxy.autoconfig_url", "");
|
||||
// Strip off paths when sending URLs to PAC scripts
|
||||
pref("network.proxy.autoconfig_url.include_path", false);
|
||||
|
||||
// If we cannot load the PAC file, then try again (doubling from interval_min
|
||||
// until we reach interval_max or the PAC file is successfully loaded).
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsIDNSService.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIURLParser.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "prnetdb.h"
|
||||
|
@ -388,6 +389,7 @@ ProxyAutoConfig::ProxyAutoConfig()
|
|||
: mJSContext(nullptr)
|
||||
, mJSNeedsSetup(false)
|
||||
, mShutdown(false)
|
||||
, mIncludePath(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ProxyAutoConfig);
|
||||
}
|
||||
|
@ -732,7 +734,8 @@ ProxyAutoConfig::SetThreadLocalIndex(uint32_t index)
|
|||
|
||||
nsresult
|
||||
ProxyAutoConfig::Init(const nsCString &aPACURI,
|
||||
const nsCString &aPACScript)
|
||||
const nsCString &aPACScript,
|
||||
bool aIncludePath)
|
||||
{
|
||||
mPACURI = aPACURI;
|
||||
mPACScript = sPacUtils;
|
||||
|
@ -741,6 +744,7 @@ ProxyAutoConfig::Init(const nsCString &aPACURI,
|
|||
if (!GetRunning())
|
||||
return SetupJS();
|
||||
|
||||
mIncludePath = aIncludePath;
|
||||
mJSNeedsSetup = true;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -838,7 +842,33 @@ ProxyAutoConfig::GetProxyForURI(const nsCString &aTestURI,
|
|||
mRunningIsInIsolatedMozBrowser = aIsInIsolatedMozBrowser;
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
JS::RootedString uriString(cx, JS_NewStringCopyZ(cx, aTestURI.get()));
|
||||
nsCString clensedURI = aTestURI;
|
||||
|
||||
if (!mIncludePath) {
|
||||
nsCOMPtr<nsIURLParser> urlParser =
|
||||
do_GetService(NS_STDURLPARSER_CONTRACTID);
|
||||
int32_t pathLen = 0;
|
||||
if (urlParser) {
|
||||
uint32_t schemePos;
|
||||
int32_t schemeLen;
|
||||
uint32_t authorityPos;
|
||||
int32_t authorityLen;
|
||||
uint32_t pathPos;
|
||||
rv = urlParser->ParseURL(aTestURI.get(), aTestURI.Length(),
|
||||
&schemePos, &schemeLen,
|
||||
&authorityPos, &authorityLen,
|
||||
&pathPos, &pathLen);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (pathLen) {
|
||||
// cut off the path but leave the initial slash
|
||||
pathLen--;
|
||||
}
|
||||
aTestURI.Left(clensedURI, aTestURI.Length() - pathLen);
|
||||
}
|
||||
}
|
||||
|
||||
JS::RootedString uriString(cx, JS_NewStringCopyZ(cx, clensedURI.get()));
|
||||
JS::RootedString hostString(cx, JS_NewStringCopyZ(cx, aTestHost.get()));
|
||||
|
||||
if (uriString && hostString) {
|
||||
|
|
|
@ -30,7 +30,8 @@ public:
|
|||
~ProxyAutoConfig();
|
||||
|
||||
nsresult Init(const nsCString &aPACURI,
|
||||
const nsCString &aPACScript);
|
||||
const nsCString &aPACScript,
|
||||
bool aIncludePath);
|
||||
void SetThreadLocalIndex(uint32_t index);
|
||||
void Shutdown();
|
||||
void GC();
|
||||
|
@ -108,6 +109,7 @@ private:
|
|||
bool mShutdown;
|
||||
nsCString mPACScript;
|
||||
nsCString mPACURI;
|
||||
bool mIncludePath;
|
||||
nsCString mRunningHost;
|
||||
uint32_t mRunningAppId;
|
||||
nsString mRunningAppOrigin;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsISystemProxySettings.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -207,7 +208,8 @@ public:
|
|||
mSetupPAC = false;
|
||||
|
||||
mPACMan->mPAC.Init(mSetupPACURI,
|
||||
mSetupPACData);
|
||||
mSetupPACData,
|
||||
mPACMan->mIncludePath);
|
||||
|
||||
RefPtr<PACLoadComplete> runnable = new PACLoadComplete(mPACMan);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
|
@ -299,6 +301,9 @@ PendingPACQuery::Run()
|
|||
static bool sThreadLocalSetup = false;
|
||||
static uint32_t sThreadLocalIndex = 0xdeadbeef; // out of range
|
||||
|
||||
static const char *kPACIncludePath =
|
||||
"network.proxy.autoconfig_url.include_path";
|
||||
|
||||
nsPACMan::nsPACMan()
|
||||
: mLoadPending(false)
|
||||
, mShutdown(false)
|
||||
|
@ -311,6 +316,7 @@ nsPACMan::nsPACMan()
|
|||
PR_NewThreadPrivateIndex(&sThreadLocalIndex, nullptr);
|
||||
}
|
||||
mPAC.SetThreadLocalIndex(sThreadLocalIndex);
|
||||
mIncludePath = Preferences::GetBool(kPACIncludePath, false);
|
||||
}
|
||||
|
||||
nsPACMan::~nsPACMan()
|
||||
|
|
|
@ -247,6 +247,7 @@ private:
|
|||
uint32_t mLoadFailureCount;
|
||||
|
||||
bool mInProgress;
|
||||
bool mIncludePath;
|
||||
};
|
||||
|
||||
extern LazyLogModule gProxyLog;
|
||||
|
|
Загрузка…
Ссылка в новой задаче