Protect document.open and document.close against some potential problems. bug 343168, r+sr=bzbarsky

This commit is contained in:
mrbkap%gmail.com 2006-08-01 21:48:03 +00:00
parent 67dac32d21
commit a4bc274aec
2 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -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");