Propagate the principal responsible an image load all the way to
CanLoadImage/LoadImage in nsContentUtils, and use it for security checks there. Bug 310165, r=sicking, sr=dbaron git-svn-id: svn://10.0.0.236/trunk@229261 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2056,10 +2056,12 @@ nsContentUtils::SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
PRBool
|
||||
nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||
nsIDocument* aLoadingDocument,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
PRInt16* aImageBlockingStatus)
|
||||
{
|
||||
NS_PRECONDITION(aURI, "Must have a URI");
|
||||
NS_PRECONDITION(aLoadingDocument, "Must have a document");
|
||||
NS_PRECONDITION(aLoadingPrincipal, "Must have a loading principal");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@@ -2084,9 +2086,10 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||
|
||||
if (appType != nsIDocShell::APP_TYPE_EDITOR) {
|
||||
// Editor apps get special treatment here, editors can load images
|
||||
// from anywhere.
|
||||
// from anywhere. This allows editor to insert images from file://
|
||||
// into documents that are being edited.
|
||||
rv = sSecurityManager->
|
||||
CheckLoadURIWithPrincipal(aLoadingDocument->NodePrincipal(), aURI,
|
||||
CheckLoadURIWithPrincipal(aLoadingPrincipal, aURI,
|
||||
nsIScriptSecurityManager::ALLOW_CHROME);
|
||||
if (NS_FAILED(rv)) {
|
||||
if (aImageBlockingStatus) {
|
||||
@@ -2098,11 +2101,15 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> loadingURI;
|
||||
nsresult rv = aLoadingPrincipal->GetURI(getter_AddRefs(loadingURI));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRInt16 decision = nsIContentPolicy::ACCEPT;
|
||||
|
||||
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_IMAGE,
|
||||
aURI,
|
||||
aLoadingDocument->GetDocumentURI(),
|
||||
loadingURI,
|
||||
aContext,
|
||||
EmptyCString(), //mime guess
|
||||
nsnull, //extra
|
||||
@@ -2119,11 +2126,13 @@ nsContentUtils::CanLoadImage(nsIURI* aURI, nsISupports* aContext,
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
|
||||
nsIURI* aReferrer, imgIDecoderObserver* aObserver,
|
||||
PRInt32 aLoadFlags, imgIRequest** aRequest)
|
||||
nsIPrincipal* aLoadingPrincipal, nsIURI* aReferrer,
|
||||
imgIDecoderObserver* aObserver, PRInt32 aLoadFlags,
|
||||
imgIRequest** aRequest)
|
||||
{
|
||||
NS_PRECONDITION(aURI, "Must have a URI");
|
||||
NS_PRECONDITION(aLoadingDocument, "Must have a document");
|
||||
NS_PRECONDITION(aLoadingPrincipal, "Must have a principal");
|
||||
NS_PRECONDITION(aRequest, "Null out param");
|
||||
|
||||
if (!sImgLoader) {
|
||||
@@ -2136,6 +2145,9 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument,
|
||||
|
||||
nsIURI *documentURI = aLoadingDocument->GetDocumentURI();
|
||||
|
||||
// We don't use aLoadingPrincipal for anything here yet... but we
|
||||
// will. See bug 377092.
|
||||
|
||||
// XXXbz using "documentURI" for the initialDocumentURI is not quite
|
||||
// right, but the best we can do here...
|
||||
return sImgLoader->LoadImage(aURI, /* uri to load */
|
||||
|
||||
Reference in New Issue
Block a user