mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1211590 - Inherits OriginAttributes from loading principal for GetChannelURIPrincipal. r=sicking
This commit is contained in:
parent
bbcb84cc7b
commit
b02a011eef
@ -401,12 +401,34 @@ nsScriptSecurityManager::GetChannelURIPrincipal(nsIChannel* aChannel,
|
||||
nsCOMPtr<nsILoadContext> loadContext;
|
||||
NS_QueryNotificationCallbacks(aChannel, loadContext);
|
||||
|
||||
if (loadContext) {
|
||||
return GetLoadContextCodebasePrincipal(uri, loadContext, aPrincipal);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
nsContentPolicyType contentPolicyType = nsIContentPolicy::TYPE_INVALID;
|
||||
if (loadInfo) {
|
||||
contentPolicyType = loadInfo->GetExternalContentPolicyType();
|
||||
}
|
||||
|
||||
PrincipalOriginAttributes attrs;
|
||||
if (nsIContentPolicy::TYPE_DOCUMENT == contentPolicyType ||
|
||||
nsIContentPolicy::TYPE_SUBDOCUMENT == contentPolicyType) {
|
||||
// If it's document or sub-document, inherit originAttributes from
|
||||
// the document.
|
||||
if (loadContext) {
|
||||
DocShellOriginAttributes docShellAttrs;
|
||||
loadContext->GetOriginAttributes(docShellAttrs);
|
||||
attrs.InheritFromDocShellToDoc(docShellAttrs, uri);
|
||||
}
|
||||
} else {
|
||||
// Inherit origin attributes from loading principal if any.
|
||||
nsCOMPtr<nsIPrincipal> loadingPrincipal;
|
||||
if (loadInfo) {
|
||||
loadInfo->GetLoadingPrincipal(getter_AddRefs(loadingPrincipal));
|
||||
}
|
||||
if (loadingPrincipal) {
|
||||
attrs = BasePrincipal::Cast(loadingPrincipal)->OriginAttributesRef();
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Bug 1211590. inherit Origin Attributes from LoadInfo.
|
||||
PrincipalOriginAttributes attrs(UNKNOWN_APP_ID, false);
|
||||
rv = MaybeSetAddonIdFromURI(attrs, uri);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
|
Loading…
Reference in New Issue
Block a user