diff --git a/content/base/public/nsContentPolicyUtils.h b/content/base/public/nsContentPolicyUtils.h index f3790607dffe..e81181f4fc82 100644 --- a/content/base/public/nsContentPolicyUtils.h +++ b/content/base/public/nsContentPolicyUtils.h @@ -193,8 +193,6 @@ NS_CP_ContentTypeName(PRUint32 contentType) } \ nsresult rv = originPrincipal->GetURI(getter_AddRefs(requestOrigin)); \ NS_ENSURE_SUCCESS(rv, rv); \ - } else { \ - requestOrigin = originURI; \ } \ PR_END_MACRO @@ -203,13 +201,13 @@ NS_CP_ContentTypeName(PRUint32 contentType) * the same as nsIContentPolicy::shouldLoad, except for the originPrincipal * parameter, which should be non-null if possible, and the last two * parameters, which can be used to pass in pointer to some useful services if - * the caller already has them. |originURI| is only used if |originPrincipal| - * is null. + * the caller already has them. The origin URI to pass to shouldLoad will be + * the URI of originPrincipal, unless originPrincipal is null (in which case a + * null origin URI will be passed). */ inline nsresult NS_CheckContentLoadPolicy(PRUint32 contentType, nsIURI *contentLocation, - nsIURI *originURI, nsIPrincipal *originPrincipal, nsISupports *context, const nsACString &mimeType, @@ -230,13 +228,13 @@ NS_CheckContentLoadPolicy(PRUint32 contentType, * are the same as nsIContentPolicy::shouldLoad, except for the originPrincipal * parameter, which should be non-null if possible, and the last two * parameters, which can be used to pass in pointer to some useful services if - * the caller already has them. |originURI| is only used if |originPrincipal| - * is null. + * the caller already has them. The origin URI to pass to shouldLoad will be + * the URI of originPrincipal, unless originPrincipal is null (in which case a + * null origin URI will be passed). */ inline nsresult NS_CheckContentProcessPolicy(PRUint32 contentType, nsIURI *contentLocation, - nsIURI *originURI, nsIPrincipal *originPrincipal, nsISupports *context, const nsACString &mimeType, diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 1c6d7adc1b12..53d1a6c15f9b 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -2120,7 +2120,6 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext, rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_IMAGE, aURI, - nsnull, aLoadingPrincipal, aContext, EmptyCString(), //mime guess @@ -3621,7 +3620,6 @@ nsContentUtils::CheckSecurityBeforeLoad(nsIURI* aURIToLoad, PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(aContentPolicyType, aURIToLoad, - nsnull, aLoadingPrincipal, aContext, aMimeGuess, diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 9f799dcad19e..95f0ee5b4617 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -891,7 +891,6 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI, rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT, aURI, - nsnull, doc->NodePrincipal(), static_cast(this), aTypeHint, diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index b27cd9d2a531..146f99ff679b 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -427,7 +427,6 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement) PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SCRIPT, scriptURI, - nsnull, mDocument->NodePrincipal(), aElement, NS_LossyConvertUTF16toASCII(type), diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 0f9a63735587..8322ac716364 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -1264,7 +1264,6 @@ nsXMLHttpRequest::OpenRequest(const nsACString& method, PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST, uri, - nsnull, (doc ? doc->NodePrincipal() : nsnull), doc, EmptyCString(), //mime guess diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp index cb35b226f807..8e5abe6809ce 100644 --- a/content/html/document/src/nsImageDocument.cpp +++ b/content/html/document/src/nsImageDocument.cpp @@ -195,7 +195,6 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt) PRInt16 decision = nsIContentPolicy::ACCEPT; nsresult rv = NS_CheckContentProcessPolicy(nsIContentPolicy::TYPE_IMAGE, channelURI, - nsnull, channelPrincipal, domWindow->GetFrameElementInternal(), mimeType, diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 82d796fa88aa..e81d8fd0db34 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -763,7 +763,6 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement, PRInt16 decision = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET, url, - nsnull, mDocument->NodePrincipal(), aElement, type, diff --git a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp index 9c3363a75c4b..7da9f8100b80 100644 --- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp @@ -448,7 +448,7 @@ CheckLoadURI(nsIURI *aUri, nsIURI *aReferrerUri, // Then do a content policy check. PRInt16 decision = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET, - aUri, nsnull, aReferrerPrincipal, aContext, + aUri, aReferrerPrincipal, aContext, NS_LITERAL_CSTRING("application/xml"), nsnull, &decision, nsContentUtils::GetContentPolicy(), diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 198c69a45ef8..626fc8cb7a52 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -6379,11 +6379,21 @@ nsDocShell::InternalLoad(nsIURI * aURI, if (!context) { context = mScriptGlobal; } + // XXXbz would be nice to know the loading principal here... but we don't + nsCOMPtr loadingPrincipal; + if (aReferrer) { + nsCOMPtr secMan = + do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + rv = secMan->GetCodebasePrincipal(aReferrer, + getter_AddRefs(loadingPrincipal)); + } + rv = NS_CheckContentLoadPolicy(contentType, aURI, - aReferrer, - nsnull, + loadingPrincipal, context, EmptyCString(), //mime guess nsnull, //extra diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index 224e5597d16d..883b11b28b88 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -222,7 +222,6 @@ CheckPingURI(nsIURI* uri, nsIContent* content) PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_PING, uri, - nsnull, content->NodePrincipal(), content, EmptyCString(), // mime hint diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp index 3167aeeb384d..55d0af685588 100644 --- a/layout/style/nsCSSLoader.cpp +++ b/layout/style/nsCSSLoader.cpp @@ -952,7 +952,6 @@ CSSLoaderImpl::CheckLoadAllowed(nsIPrincipal* aSourcePrincipal, PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET, aTargetURI, - nsnull, aSourcePrincipal, aContext, NS_LITERAL_CSTRING("text/css"), diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 08bb459b5e42..a909d5a7b470 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -3457,7 +3457,6 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbeddedPlugin(const char *aMimeType, nsresult rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT, aURL, - nsnull, doc->NodePrincipal(), elem, nsDependentCString(aMimeType ? aMimeType : ""), @@ -5910,7 +5909,6 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, PRInt16 shouldLoad = nsIContentPolicy::ACCEPT; rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT_SUBREQUEST, url, - nsnull, (doc ? doc->NodePrincipal() : nsnull), element, EmptyCString(), //mime guess