Bug 1199049 - Part 11: Make it impossible to start CORS preflights from outside of Necko; r=jduell,ckerschb,sicking

This commit is contained in:
Ehsan Akhgari 2015-08-28 11:25:04 -04:00
parent 7d7e51e295
commit cd8364d48a
3 changed files with 30 additions and 25 deletions

View File

@ -1290,13 +1290,13 @@ nsCORSListenerProxy::RemoveFromCorsPreflightCache(nsIURI* aURI,
}
nsresult
NS_StartCORSPreflight(nsIChannel* aRequestChannel,
nsIStreamListener* aListener,
nsIPrincipal* aPrincipal,
nsICorsPreflightCallback* aCallback,
bool aWithCredentials,
nsTArray<nsCString>& aUnsafeHeaders,
nsIChannel** aPreflightChannel)
nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel,
nsIStreamListener* aListener,
nsIPrincipal* aPrincipal,
nsICorsPreflightCallback* aCallback,
bool aWithCredentials,
nsTArray<nsCString>& aUnsafeHeaders,
nsIChannel** aPreflightChannel)
{
*aPreflightChannel = nullptr;

View File

@ -24,18 +24,10 @@ class nsIPrincipal;
class nsINetworkInterceptController;
class nsICorsPreflightCallback;
nsresult
NS_StartCORSPreflight(nsIChannel* aRequestChannel,
nsIStreamListener* aListener,
nsIPrincipal* aPrincipal,
nsICorsPreflightCallback* aCallback,
bool aWithCredentials,
nsTArray<nsCString>& aACUnsafeHeaders,
nsIChannel** aPreflightChannel);
namespace mozilla {
namespace net {
class HttpChannelParent;
class nsHttpChannel;
}
}
@ -55,11 +47,6 @@ public:
nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
bool aWithCredentials);
nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
bool aWithCredentials,
const nsCString& aPreflightMethod,
const nsTArray<nsCString>& aPreflightHeaders);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
@ -81,10 +68,26 @@ public:
private:
// Only HttpChannelParent can call RemoveFromCorsPreflightCache
friend class mozilla::net::HttpChannelParent;
// Only nsHttpChannel can invoke CORS preflights
friend class mozilla::net::nsHttpChannel;
static void RemoveFromCorsPreflightCache(nsIURI* aURI,
nsIPrincipal* aRequestingPrincipal);
nsCORSListenerProxy(nsIStreamListener* aOuter,
nsIPrincipal* aRequestingPrincipal,
bool aWithCredentials,
const nsCString& aPreflightMethod,
const nsTArray<nsCString>& aPreflightHeaders);
static nsresult StartCORSPreflight(nsIChannel* aRequestChannel,
nsIStreamListener* aListener,
nsIPrincipal* aPrincipal,
nsICorsPreflightCallback* aCallback,
bool aWithCredentials,
nsTArray<nsCString>& aACUnsafeHeaders,
nsIChannel** aPreflightChannel);
~nsCORSListenerProxy();
nsresult UpdateChannel(nsIChannel* aChannel, DataURIHandling aAllowDataURI);

View File

@ -453,10 +453,12 @@ nsHttpChannel::ContinueConnect()
if (!mIsCorsPreflightDone && mRequireCORSPreflight &&
mInterceptCache != INTERCEPTED) {
nsCOMPtr<nsIChannel> preflightChannel;
nsresult rv = NS_StartCORSPreflight(this, mListener,
mPreflightPrincipal, this,
mWithCredentials, mUnsafeHeaders,
getter_AddRefs(preflightChannel));
nsresult rv =
nsCORSListenerProxy::StartCORSPreflight(this, mListener,
mPreflightPrincipal, this,
mWithCredentials,
mUnsafeHeaders,
getter_AddRefs(preflightChannel));
return rv;
}