зеркало из https://github.com/mozilla/gecko-dev.git
Bug 780351 - Don't let code in different apps access each others' windows. r=smaug
This commit is contained in:
Родитель
02bd55ec18
Коммит
233a0bf81b
|
@ -2846,7 +2846,10 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|||
// window with javascript
|
||||
// Bug 408052: Adopt "ancestor" frame navigation policy
|
||||
|
||||
// Now do a security check
|
||||
// Now do a security check.
|
||||
//
|
||||
// Disallow navigation if the two frames are not part of the same app, or if
|
||||
// they have different is-in-browser-element states.
|
||||
//
|
||||
// Allow navigation if
|
||||
// 1) aAccessingItem can script aTargetItem or one of its ancestors in
|
||||
|
@ -2857,7 +2860,29 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|||
|
||||
if (aTargetItem == aAccessingItem) {
|
||||
// A frame is allowed to navigate itself.
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> targetDS = do_QueryInterface(aTargetItem);
|
||||
nsCOMPtr<nsIDocShell> accessingDS = do_QueryInterface(aAccessingItem);
|
||||
if (!!targetDS != !!accessingDS) {
|
||||
// We must be able to convert both or neither to nsIDocShell.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetDS && accessingDS) {
|
||||
bool targetInBrowser = false, accessingInBrowser = false;
|
||||
targetDS->GetIsInBrowserElement(&targetInBrowser);
|
||||
accessingDS->GetIsInBrowserElement(&accessingInBrowser);
|
||||
|
||||
PRUint32 targetAppId = 0, accessingAppId = 0;
|
||||
targetDS->GetAppId(&targetAppId);
|
||||
accessingDS->GetAppId(&accessingAppId);
|
||||
|
||||
if (targetInBrowser != accessingInBrowser ||
|
||||
targetAppId != accessingAppId) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> accessingRoot;
|
||||
|
|
Загрузка…
Ссылка в новой задаче