diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-06-24 14:11:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-24 14:11:54 +0200 |
commit | 3c1ab00ffb1b41e372f322e3b46b7232a9be0518 (patch) | |
tree | 1ba580e017e0f428b6bb33a7872d520d6a9c8928 /netwerk | |
parent | a7b6be69cb0dc6364d4655892eefcd38a9c70104 (diff) | |
parent | c9572541003234b67a9ca76b9da6a2bb791ceb6a (diff) | |
download | aura-central-3c1ab00ffb1b41e372f322e3b46b7232a9be0518.tar.gz |
Merge pull request %540 from janekptacijarabaci/security_csp_script_redirect_1
Fix CSP: Scripts with valid nonce should not be blocked if URL redirects
Diffstat (limited to 'netwerk')
-rw-r--r-- | netwerk/base/LoadInfo.cpp | 23 | ||||
-rw-r--r-- | netwerk/base/nsILoadInfo.idl | 17 |
2 files changed, 38 insertions, 2 deletions
diff --git a/netwerk/base/LoadInfo.cpp b/netwerk/base/LoadInfo.cpp index a8c9a5a25..ebe9d4703 100644 --- a/netwerk/base/LoadInfo.cpp +++ b/netwerk/base/LoadInfo.cpp @@ -81,7 +81,7 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal, // This constructor shouldn't be used for TYPE_DOCUMENT loads that don't // have a loadingPrincipal - MOZ_ASSERT(skipContentTypeCheck || + MOZ_ASSERT(skipContentTypeCheck || mLoadingPrincipal || mInternalContentPolicyType != nsIContentPolicy::TYPE_DOCUMENT); // TODO(bug 1259873): Above, we initialize mIsThirdPartyContext to false meaning @@ -493,6 +493,27 @@ LoadInfo::ContextForTopLevelLoad() return context; } +already_AddRefed<nsISupports> +LoadInfo::GetLoadingContext() +{ + nsCOMPtr<nsISupports> context; + if (mInternalContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT) { + context = ContextForTopLevelLoad(); + } + else { + context = LoadingNode(); + } + return context.forget(); +} + +NS_IMETHODIMP +LoadInfo::GetLoadingContextXPCOM(nsISupports** aResult) +{ + nsCOMPtr<nsISupports> context = GetLoadingContext(); + context.forget(aResult); + return NS_OK; +} + NS_IMETHODIMP LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult) { diff --git a/netwerk/base/nsILoadInfo.idl b/netwerk/base/nsILoadInfo.idl index 9a883ff98..bc609c317 100644 --- a/netwerk/base/nsILoadInfo.idl +++ b/netwerk/base/nsILoadInfo.idl @@ -10,7 +10,7 @@ interface nsIDOMDocument; interface nsINode; interface nsIPrincipal; - +native LoadContextRef(already_AddRefed<nsISupports>); %{C++ #include "nsTArray.h" #include "mozilla/BasePrincipal.h" @@ -334,6 +334,21 @@ interface nsILoadInfo : nsISupports nsISupports binaryContextForTopLevelLoad(); /** + * For all loads except loads of TYPE_DOCUMENT, the loadingContext + * simply returns the loadingNode. For loads of TYPE_DOCUMENT this + * will return the context available for top-level loads which + * do not have a loadingNode. + */ + [binaryname(LoadingContextXPCOM)] + readonly attribute nsISupports loadingContext; + + /** + * A C++ friendly version of the loadingContext. + */ + [noscript, notxpcom, nostdcall, binaryname(GetLoadingContext)] + LoadContextRef binaryGetLoadingContext(); + + /** * The securityFlags of that channel. */ readonly attribute nsSecurityFlags securityFlags; |