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:
bzbarsky@mit.edu 2007-08-09 22:35:08 -07:00
Родитель 25a3f52e56
Коммит bd826c03d9
12 изменённых файлов: 19 добавлений и 22 удалений

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

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

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

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

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

@ -891,7 +891,6 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
rv =
NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_OBJECT,
aURI,
nsnull,
doc->NodePrincipal(),
static_cast<nsIImageLoadingContent*>(this),
aTypeHint,

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

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

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

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

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

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

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

@ -763,7 +763,6 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
PRInt16 decision = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_STYLESHEET,
url,
nsnull,
mDocument->NodePrincipal(),
aElement,
type,

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

@ -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(),

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

@ -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<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,
aURI,
aReferrer,
nsnull,
loadingPrincipal,
context,
EmptyCString(), //mime guess
nsnull, //extra

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

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

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

@ -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"),

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

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