Bug 1105556 - Call Create(originAttributes) when loadinfo->loadingPrincipal is null, instead of CreatePrincipalWithInheritedAttributes(). r=sicking

This commit is contained in:
Tanvi Vyas 2016-04-13 16:30:22 -07:00
Родитель 1e5f23269c
Коммит c73e96a53d
2 изменённых файлов: 27 добавлений и 6 удалений

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

@ -344,9 +344,19 @@ nsScriptSecurityManager::GetChannelResultPrincipal(nsIChannel* aChannel,
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
if (loadInfo) {
if (loadInfo->GetLoadingSandboxed()) {
RefPtr<nsNullPrincipal> prin =
nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal());
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
RefPtr<nsNullPrincipal> prin;
if (loadInfo->LoadingPrincipal()) {
prin =
nsNullPrincipal::CreateWithInheritedAttributes(loadInfo->LoadingPrincipal());
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
} else {
NeckoOriginAttributes nAttrs;
loadInfo->GetOriginAttributes(&nAttrs);
PrincipalOriginAttributes pAttrs;
pAttrs.InheritFromNecko(nAttrs);
prin = nsNullPrincipal::Create(pAttrs);
NS_ENSURE_TRUE(prin, NS_ERROR_FAILURE);
}
prin.forget(aPrincipal);
return NS_OK;
}

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

@ -12048,9 +12048,20 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
if (loadInfo) {
// For now keep storing just the principal in the SHEntry.
if (loadInfo->GetLoadingSandboxed()) {
owner = nsNullPrincipal::CreateWithInheritedAttributes(
loadInfo->LoadingPrincipal());
NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
if (loadInfo->LoadingPrincipal()) {
owner = nsNullPrincipal::CreateWithInheritedAttributes(
loadInfo->LoadingPrincipal());
NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
} else {
// get the OriginAttributes
NeckoOriginAttributes nAttrs;
loadInfo->GetOriginAttributes(&nAttrs);
PrincipalOriginAttributes pAttrs;
pAttrs.InheritFromNecko(nAttrs);
owner = nsNullPrincipal::Create(pAttrs);
NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
}
} else if (loadInfo->GetForceInheritPrincipal()) {
owner = loadInfo->TriggeringPrincipal();
}