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
Родитель b64a770b94
Коммит b511946ddc
3 изменённых файлов: 30 добавлений и 25 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;
}