зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1022229 - Borrow App ID and mozBrowser-ness when creating sandbox null principals. r=bz
This commit is contained in:
Родитель
4adfe5c438
Коммит
f6516d5622
|
@ -68,6 +68,15 @@ nsNullPrincipal::~nsNullPrincipal()
|
|||
{
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsNullPrincipal>
|
||||
nsNullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
|
||||
{
|
||||
nsRefPtr<nsNullPrincipal> nullPrin = new nsNullPrincipal();
|
||||
nsresult rv = nullPrin->Init(aInheritFrom->GetAppId(),
|
||||
aInheritFrom->GetIsInBrowserElement());
|
||||
return NS_SUCCEEDED(rv) ? nullPrin.forget() : nullptr;
|
||||
}
|
||||
|
||||
#define NS_NULLPRINCIPAL_PREFIX NS_NULLPRINCIPAL_SCHEME ":"
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
NS_DECL_NSIPRINCIPAL
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
|
||||
static already_AddRefed<nsNullPrincipal> CreateWithInheritedAttributes(nsIPrincipal *aInheritFrom);
|
||||
|
||||
nsresult Init(uint32_t aAppId = nsIScriptSecurityManager::NO_APP_ID,
|
||||
bool aInMozBrowser = false);
|
||||
|
||||
|
|
|
@ -324,7 +324,11 @@ nsScriptSecurityManager::GetChannelPrincipal(nsIChannel* aChannel,
|
|||
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
if (loadInfo) {
|
||||
if (loadInfo->GetLoadingSandboxed()) {
|
||||
return CallCreateInstance(NS_NULLPRINCIPAL_CONTRACTID, aPrincipal);
|
||||
nsRefPtr<nsNullPrincipal> prin =
|
||||
nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal());
|
||||
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
|
||||
prin.forget(aPrincipal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (loadInfo->GetForceInheritPrincipal()) {
|
||||
|
|
|
@ -7415,7 +7415,8 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
|
|||
if (docFactory) {
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
if (mSandboxFlags & SANDBOXED_ORIGIN) {
|
||||
principal = do_CreateInstance("@mozilla.org/nullprincipal;1");
|
||||
principal = nsNullPrincipal::CreateWithInheritedAttributes(aPrincipal);
|
||||
NS_ENSURE_TRUE(principal, NS_ERROR_FAILURE);
|
||||
} else {
|
||||
principal = aPrincipal;
|
||||
}
|
||||
|
@ -11146,10 +11147,8 @@ nsDocShell::AddToSessionHistory(nsIURI * aURI, nsIChannel * aChannel,
|
|||
if (loadInfo) {
|
||||
// For now keep storing just the principal in the SHEntry.
|
||||
if (loadInfo->GetLoadingSandboxed()) {
|
||||
owner = do_CreateInstance(NS_NULLPRINCIPAL_CONTRACTID, &rv);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
owner = nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal());
|
||||
NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
|
||||
} else if (loadInfo->GetForceInheritPrincipal()) {
|
||||
owner = loadInfo->LoadingPrincipal();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче