mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1011024 - Fix nsScriptSecurityManager::GetChannelPrincipal so that it doesn't fail to get the correct nsIPrincipal for some resource documents. r=bz
This commit is contained in:
parent
2111418e01
commit
3cf8ef7d61
@ -10,8 +10,9 @@ interface nsIURI;
|
|||||||
interface nsIChannel;
|
interface nsIChannel;
|
||||||
interface nsIDocShell;
|
interface nsIDocShell;
|
||||||
interface nsIDomainPolicy;
|
interface nsIDomainPolicy;
|
||||||
|
interface nsILoadContext;
|
||||||
|
|
||||||
[scriptable, uuid(2565769a-eaec-47a1-a076-605f5294d286)]
|
[scriptable, uuid(9875f4b2-f9cd-41d1-a461-fe14956823ac)]
|
||||||
interface nsIScriptSecurityManager : nsIXPCSecurityManager
|
interface nsIScriptSecurityManager : nsIXPCSecurityManager
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -122,6 +123,14 @@ interface nsIScriptSecurityManager : nsIXPCSecurityManager
|
|||||||
in unsigned long appId,
|
in unsigned long appId,
|
||||||
in boolean inMozBrowser);
|
in boolean inMozBrowser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a principal that has the appId and inMozBrowser of the load
|
||||||
|
* context.
|
||||||
|
* @param loadContext to get appId/inMozBrowser from.
|
||||||
|
*/
|
||||||
|
nsIPrincipal getLoadContextCodebasePrincipal(in nsIURI uri,
|
||||||
|
in nsILoadContext loadContext);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a principal that has the appId and inMozBrowser of the docshell
|
* Returns a principal that has the appId and inMozBrowser of the docshell
|
||||||
* inside a mozbrowser frame.
|
* inside a mozbrowser frame.
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "js/OldDebugAPI.h"
|
#include "js/OldDebugAPI.h"
|
||||||
#include "xpcprivate.h"
|
#include "xpcprivate.h"
|
||||||
#include "XPCWrapper.h"
|
#include "XPCWrapper.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIScriptObjectPrincipal.h"
|
#include "nsIScriptObjectPrincipal.h"
|
||||||
#include "nsIScriptContext.h"
|
#include "nsIScriptContext.h"
|
||||||
@ -295,11 +296,12 @@ nsScriptSecurityManager::GetChannelPrincipal(nsIChannel* aChannel,
|
|||||||
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShell> docShell;
|
|
||||||
NS_QueryNotificationCallbacks(aChannel, docShell);
|
|
||||||
|
|
||||||
if (docShell) {
|
nsCOMPtr<nsILoadContext> loadContext;
|
||||||
return GetDocShellCodebasePrincipal(uri, docShell, aPrincipal);
|
NS_QueryNotificationCallbacks(aChannel, loadContext);
|
||||||
|
|
||||||
|
if (loadContext) {
|
||||||
|
return GetLoadContextCodebasePrincipal(uri, loadContext, aPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetCodebasePrincipalInternal(uri, UNKNOWN_APP_ID,
|
return GetCodebasePrincipalInternal(uri, UNKNOWN_APP_ID,
|
||||||
@ -969,6 +971,22 @@ nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
|
|||||||
return GetCodebasePrincipalInternal(aURI, aAppId, aInMozBrowser, aPrincipal);
|
return GetCodebasePrincipalInternal(aURI, aAppId, aInMozBrowser, aPrincipal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsScriptSecurityManager::
|
||||||
|
GetLoadContextCodebasePrincipal(nsIURI* aURI,
|
||||||
|
nsILoadContext* aLoadContext,
|
||||||
|
nsIPrincipal** aPrincipal)
|
||||||
|
{
|
||||||
|
uint32_t appId;
|
||||||
|
aLoadContext->GetAppId(&appId);
|
||||||
|
bool isInBrowserElement;
|
||||||
|
aLoadContext->GetIsInBrowserElement(&isInBrowserElement);
|
||||||
|
return GetCodebasePrincipalInternal(aURI,
|
||||||
|
appId,
|
||||||
|
isInBrowserElement,
|
||||||
|
aPrincipal);
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
|
nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
|
||||||
nsIDocShell* aDocShell,
|
nsIDocShell* aDocShell,
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
|
#include "nsILoadContext.h"
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
#include "nsContentList.h"
|
#include "nsContentList.h"
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
@ -2337,21 +2338,21 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
|||||||
nsIScriptSecurityManager *securityManager =
|
nsIScriptSecurityManager *securityManager =
|
||||||
nsContentUtils::GetSecurityManager();
|
nsContentUtils::GetSecurityManager();
|
||||||
if (securityManager) {
|
if (securityManager) {
|
||||||
nsCOMPtr<nsIDocShell> docShell(mDocumentContainer);
|
nsCOMPtr<nsILoadContext> loadContext(mDocumentContainer);
|
||||||
|
|
||||||
if (!docShell && aLoadGroup) {
|
if (!loadContext && aLoadGroup) {
|
||||||
nsCOMPtr<nsIInterfaceRequestor> cbs;
|
nsCOMPtr<nsIInterfaceRequestor> cbs;
|
||||||
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
|
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(cbs));
|
||||||
docShell = do_GetInterface(cbs);
|
loadContext = do_GetInterface(cbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(docShell,
|
MOZ_ASSERT(loadContext,
|
||||||
"must be in a docshell or pass in an explicit principal");
|
"must have a load context or pass in an explicit principal");
|
||||||
|
|
||||||
nsCOMPtr<nsIPrincipal> principal;
|
nsCOMPtr<nsIPrincipal> principal;
|
||||||
nsresult rv = securityManager->
|
nsresult rv = securityManager->
|
||||||
GetDocShellCodebasePrincipal(mDocumentURI, docShell,
|
GetLoadContextCodebasePrincipal(mDocumentURI, loadContext,
|
||||||
getter_AddRefs(principal));
|
getter_AddRefs(principal));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
SetPrincipal(principal);
|
SetPrincipal(principal);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user