Protect document.open and document.close against some potential problems. bug 343168, r+sr=bzbarsky
git-svn-id: svn://10.0.0.236/trunk@206341 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1915,6 +1915,19 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsPIDOMWindow *win = GetWindow();
|
||||
if (win) {
|
||||
nsCOMPtr<nsIDOMElement> frameElement;
|
||||
rv = win->GetFrameElement(getter_AddRefs(frameElement));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (frameElement && !nsContentUtils::CanCallerAccess(frameElement)) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
// If we already have a parser we ignore the document.open call.
|
||||
if (mParser) {
|
||||
|
||||
@@ -1927,8 +1940,6 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Note: We want to use GetDocumentFromContext here because this document
|
||||
// should inherit the security information of the document that's opening us,
|
||||
// (since if it's secure, then it's presumeably trusted).
|
||||
@@ -2008,7 +2019,7 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace)
|
||||
|
||||
nsPIDOMWindow *window = GetInnerWindow();
|
||||
if (window) {
|
||||
// Rememer the old scope in case the call to SetNewDocument changes it.
|
||||
// Remember the old scope in case the call to SetNewDocument changes it.
|
||||
nsCOMPtr<nsIScriptGlobalObject> oldScope(do_QueryReferent(mScopeObject));
|
||||
|
||||
rv = window->SetNewDocument(this, nsnull, PR_FALSE);
|
||||
|
||||
@@ -279,7 +279,6 @@ pref("capability.policy.default.History.next", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.previous", "UniversalBrowserRead");
|
||||
pref("capability.policy.default.History.toString", "UniversalBrowserRead");
|
||||
|
||||
pref("capability.policy.default.HTMLDocument.close.get", "allAccess");
|
||||
pref("capability.policy.default.HTMLDocument.open.get", "allAccess");
|
||||
|
||||
pref("capability.policy.default.Location.hash.set", "allAccess");
|
||||
|
||||
Reference in New Issue
Block a user