зеркало из https://github.com/mozilla/gecko-dev.git
Make NS_CheckContent(Load|Process)Policy only take a principal, not a principal and a uri. Get the URI from the principal. Bug 391438, r+sr+a=sicking
This commit is contained in:
Родитель
25a3f52e56
Коммит
bd826c03d9
|
@ -193,8 +193,6 @@ NS_CP_ContentTypeName(PRUint32 contentType)
|
||||||
} \
|
} \
|
||||||
nsresult rv = originPrincipal->GetURI(getter_AddRefs(requestOrigin)); \
|
nsresult rv = originPrincipal->GetURI(getter_AddRefs(requestOrigin)); \
|
||||||
NS_ENSURE_SUCCESS(rv, rv); \
|
NS_ENSURE_SUCCESS(rv, rv); \
|
||||||
} else { \
|
|
||||||
requestOrigin = originURI; \
|
|
||||||
} \
|
} \
|
||||||
PR_END_MACRO
|
PR_END_MACRO
|
||||||
|
|
||||||
|
@ -203,13 +201,13 @@ NS_CP_ContentTypeName(PRUint32 contentType)
|
||||||
* the same as nsIContentPolicy::shouldLoad, except for the originPrincipal
|
* the same as nsIContentPolicy::shouldLoad, except for the originPrincipal
|
||||||
* parameter, which should be non-null if possible, and the last two
|
* 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
|
* 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|
|
* the caller already has them. The origin URI to pass to shouldLoad will be
|
||||||
* is null.
|
* the URI of originPrincipal, unless originPrincipal is null (in which case a
|
||||||
|
* null origin URI will be passed).
|
||||||
*/
|
*/
|
||||||
inline nsresult
|
inline nsresult
|
||||||
NS_CheckContentLoadPolicy(PRUint32 contentType,
|
NS_CheckContentLoadPolicy(PRUint32 contentType,
|
||||||
nsIURI *contentLocation,
|
nsIURI *contentLocation,
|
||||||
nsIURI *originURI,
|
|
||||||
nsIPrincipal *originPrincipal,
|
nsIPrincipal *originPrincipal,
|
||||||
nsISupports *context,
|
nsISupports *context,
|
||||||
const nsACString &mimeType,
|
const nsACString &mimeType,
|
||||||
|
@ -230,13 +228,13 @@ NS_CheckContentLoadPolicy(PRUint32 contentType,
|
||||||
* are the same as nsIContentPolicy::shouldLoad, except for the originPrincipal
|
* are the same as nsIContentPolicy::shouldLoad, except for the originPrincipal
|
||||||
* parameter, which should be non-null if possible, and the last two
|
* 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
|
* 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|
|
* the caller already has them. The origin URI to pass to shouldLoad will be
|
||||||
* is null.
|
* the URI of originPrincipal, unless originPrincipal is null (in which case a
|
||||||
|
* null origin URI will be passed).
|
||||||
*/
|
*/
|
||||||
inline nsresult
|
inline nsresult
|
||||||
NS_CheckContentProcessPolicy(PRUint32 contentType,
|
NS_CheckContentProcessPolicy(PRUint32 contentType,
|
||||||
nsIURI *contentLocation,
|
nsIURI *contentLocation,
|
||||||
nsIURI *originURI,
|
|
||||||
nsIPrincipal *originPrincipal,
|
nsIPrincipal *originPrincipal,
|
||||||
nsISupports *context,
|
nsISupports *context,
|
||||||
const nsACString &mimeType,
|
const nsACString &mimeType,
|
||||||
|
|
|
@ -2120,7 +2120,6 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||||
|
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_IMAGE,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_IMAGE,
|
||||||
aURI,
|
aURI,
|
||||||
nsnull,
|
|
||||||
aLoadingPrincipal,
|
aLoadingPrincipal,
|
||||||
aContext,
|
aContext,
|
||||||
EmptyCString(), //mime guess
|
EmptyCString(), //mime guess
|
||||||
|
@ -3621,7 +3620,6 @@ nsContentUtils::CheckSecurityBeforeLoad(nsIURI* aURIToLoad,
|
||||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(aContentPolicyType,
|
rv = NS_CheckContentLoadPolicy(aContentPolicyType,
|
||||||
aURIToLoad,
|
aURIToLoad,
|
||||||
nsnull,
|
|
||||||
aLoadingPrincipal,
|
aLoadingPrincipal,
|
||||||
aContext,
|
aContext,
|
||||||
aMimeGuess,
|
aMimeGuess,
|
||||||
|
|
|
@ -891,7 +891,6 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
|
||||||
rv =
|
rv =
|
||||||
NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
||||||
aURI,
|
aURI,
|
||||||
nsnull,
|
|
||||||
doc->NodePrincipal(),
|
doc->NodePrincipal(),
|
||||||
static_cast<nsIImageLoadingContent*>(this),
|
static_cast<nsIImageLoadingContent*>(this),
|
||||||
aTypeHint,
|
aTypeHint,
|
||||||
|
|
|
@ -427,7 +427,6 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
|
||||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SCRIPT,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_SCRIPT,
|
||||||
scriptURI,
|
scriptURI,
|
||||||
nsnull,
|
|
||||||
mDocument->NodePrincipal(),
|
mDocument->NodePrincipal(),
|
||||||
aElement,
|
aElement,
|
||||||
NS_LossyConvertUTF16toASCII(type),
|
NS_LossyConvertUTF16toASCII(type),
|
||||||
|
|
|
@ -1264,7 +1264,6 @@ nsXMLHttpRequest::OpenRequest(const nsACString& method,
|
||||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_XMLHTTPREQUEST,
|
||||||
uri,
|
uri,
|
||||||
nsnull,
|
|
||||||
(doc ? doc->NodePrincipal() : nsnull),
|
(doc ? doc->NodePrincipal() : nsnull),
|
||||||
doc,
|
doc,
|
||||||
EmptyCString(), //mime guess
|
EmptyCString(), //mime guess
|
||||||
|
|
|
@ -195,7 +195,6 @@ ImageListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
|
||||||
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
||||||
nsresult rv = NS_CheckContentProcessPolicy(nsIContentPolicy::TYPE_IMAGE,
|
nsresult rv = NS_CheckContentProcessPolicy(nsIContentPolicy::TYPE_IMAGE,
|
||||||
channelURI,
|
channelURI,
|
||||||
nsnull,
|
|
||||||
channelPrincipal,
|
channelPrincipal,
|
||||||
domWindow->GetFrameElementInternal(),
|
domWindow->GetFrameElementInternal(),
|
||||||
mimeType,
|
mimeType,
|
||||||
|
|
|
@ -763,7 +763,6 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||||
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
||||||
url,
|
url,
|
||||||
nsnull,
|
|
||||||
mDocument->NodePrincipal(),
|
mDocument->NodePrincipal(),
|
||||||
aElement,
|
aElement,
|
||||||
type,
|
type,
|
||||||
|
|
|
@ -448,7 +448,7 @@ CheckLoadURI(nsIURI *aUri, nsIURI *aReferrerUri,
|
||||||
// Then do a content policy check.
|
// Then do a content policy check.
|
||||||
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
||||||
aUri, nsnull, aReferrerPrincipal, aContext,
|
aUri, aReferrerPrincipal, aContext,
|
||||||
NS_LITERAL_CSTRING("application/xml"), nsnull,
|
NS_LITERAL_CSTRING("application/xml"), nsnull,
|
||||||
&decision,
|
&decision,
|
||||||
nsContentUtils::GetContentPolicy(),
|
nsContentUtils::GetContentPolicy(),
|
||||||
|
|
|
@ -6379,11 +6379,21 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
||||||
if (!context) {
|
if (!context) {
|
||||||
context = mScriptGlobal;
|
context = mScriptGlobal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXXbz would be nice to know the loading principal here... but we don't
|
// XXXbz would be nice to know the loading principal here... but we don't
|
||||||
|
nsCOMPtr<nsIPrincipal> loadingPrincipal;
|
||||||
|
if (aReferrer) {
|
||||||
|
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||||
|
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
rv = secMan->GetCodebasePrincipal(aReferrer,
|
||||||
|
getter_AddRefs(loadingPrincipal));
|
||||||
|
}
|
||||||
|
|
||||||
rv = NS_CheckContentLoadPolicy(contentType,
|
rv = NS_CheckContentLoadPolicy(contentType,
|
||||||
aURI,
|
aURI,
|
||||||
aReferrer,
|
loadingPrincipal,
|
||||||
nsnull,
|
|
||||||
context,
|
context,
|
||||||
EmptyCString(), //mime guess
|
EmptyCString(), //mime guess
|
||||||
nsnull, //extra
|
nsnull, //extra
|
||||||
|
|
|
@ -222,7 +222,6 @@ CheckPingURI(nsIURI* uri, nsIContent* content)
|
||||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_PING,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_PING,
|
||||||
uri,
|
uri,
|
||||||
nsnull,
|
|
||||||
content->NodePrincipal(),
|
content->NodePrincipal(),
|
||||||
content,
|
content,
|
||||||
EmptyCString(), // mime hint
|
EmptyCString(), // mime hint
|
||||||
|
|
|
@ -952,7 +952,6 @@ CSSLoaderImpl::CheckLoadAllowed(nsIPrincipal* aSourcePrincipal,
|
||||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
|
||||||
aTargetURI,
|
aTargetURI,
|
||||||
nsnull,
|
|
||||||
aSourcePrincipal,
|
aSourcePrincipal,
|
||||||
aContext,
|
aContext,
|
||||||
NS_LITERAL_CSTRING("text/css"),
|
NS_LITERAL_CSTRING("text/css"),
|
||||||
|
|
|
@ -3457,7 +3457,6 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
|
||||||
aURL,
|
aURL,
|
||||||
nsnull,
|
|
||||||
doc->NodePrincipal(),
|
doc->NodePrincipal(),
|
||||||
elem,
|
elem,
|
||||||
nsDependentCString(aMimeType ? aMimeType : ""),
|
nsDependentCString(aMimeType ? aMimeType : ""),
|
||||||
|
@ -5910,7 +5909,6 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL,
|
||||||
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
PRInt16 shouldLoad = nsIContentPolicy::ACCEPT;
|
||||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
|
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT_SUBREQUEST,
|
||||||
url,
|
url,
|
||||||
nsnull,
|
|
||||||
(doc ? doc->NodePrincipal() : nsnull),
|
(doc ? doc->NodePrincipal() : nsnull),
|
||||||
element,
|
element,
|
||||||
EmptyCString(), //mime guess
|
EmptyCString(), //mime guess
|
||||||
|
|
Загрузка…
Ссылка в новой задаче