From eac4ea696c1d4241c91c63883c381c82ec65d863 Mon Sep 17 00:00:00 2001 From: "norris%netscape.com" Date: Tue, 28 Mar 2000 03:59:46 +0000 Subject: [PATCH] Fix bug 7264 All JavaScript running with correct principals r=mstoltz git-svn-id: svn://10.0.0.236/trunk@64317 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xml/document/src/nsXMLContentSink.cpp | 9 +++++++-- mozilla/editor/base/nsEditorShell.cpp | 20 ------------------- mozilla/editor/base/nsEditorShell.h | 1 - mozilla/editor/composer/src/nsEditorShell.cpp | 20 ------------------- mozilla/editor/composer/src/nsEditorShell.h | 1 - .../xml/document/src/nsXMLContentSink.cpp | 9 +++++++-- .../xpfe/browser/src/nsBrowserInstance.cpp | 17 ---------------- mozilla/xpfe/browser/src/nsBrowserInstance.h | 1 - 8 files changed, 14 insertions(+), 64 deletions(-) diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 83ba7ba3d33..16781154dc3 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -1712,12 +1712,17 @@ nsXMLContentSink::EvaluateScript(nsString& aScript, PRUint32 aLineNo, const char rv = docURL->GetSpec(&url); } + nsCOMPtr principal; + if (NS_SUCCEEDED(rv)) { + rv = mDocument->GetPrincipal(getter_AddRefs(principal)); + NS_ASSERTION(principal, "principal required for document"); + } + if (NS_SUCCEEDED(rv)) { nsAutoString val; PRBool isUndefined; - // XXX need principal - (void) context->EvaluateString(aScript, nsnull, nsnull, url, aLineNo, aVersion, + (void) context->EvaluateString(aScript, nsnull, principal, url, aLineNo, aVersion, val, &isUndefined); NS_IF_RELEASE(docURL); diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index b133449ae38..77aa60601cd 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -3946,26 +3946,6 @@ void nsEditorShell::SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum, co } #endif -// XXXbe why is this needed? eliminate -NS_IMETHODIMP -nsEditorShell::ExecuteScript(nsIScriptContext * aContext, const nsString& aScript) -{ - if (nsnull != aContext) { - const char* url = ""; - PRBool isUndefined = PR_FALSE; - nsAutoString rVal; - -#ifdef APP_DEBUG - char* script_str = aScript.ToNewCString(); - printf("Executing [%s]\n", script_str); - nsCRT::free(script_str); -#endif - - aContext->EvaluateString(aScript, nsnull, nsnull, url, 0, nsnull, rVal, &isUndefined); - } - return NS_OK; -} - NS_IMETHODIMP nsEditorShell::RunUnitTests() { diff --git a/mozilla/editor/base/nsEditorShell.h b/mozilla/editor/base/nsEditorShell.h index be2e58a2701..cf0ac6dd7c9 100644 --- a/mozilla/editor/base/nsEditorShell.h +++ b/mozilla/editor/base/nsEditorShell.h @@ -108,7 +108,6 @@ class nsEditorShell : public nsIEditorShell, nsIPresShell* GetPresShellFor(nsIWebShell* aWebShell); NS_IMETHOD DoEditorMode(nsIWebShell *aWebShell); - NS_IMETHOD ExecuteScript(nsIScriptContext * aContext, const nsString& aScript); NS_IMETHOD InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); NS_IMETHOD ScrollSelectionIntoView(); NS_IMETHOD TransferDocumentStateListeners(); diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index b133449ae38..77aa60601cd 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -3946,26 +3946,6 @@ void nsEditorShell::SetButtonImage(nsIDOMNode * aParentNode, PRInt32 aBtnNum, co } #endif -// XXXbe why is this needed? eliminate -NS_IMETHODIMP -nsEditorShell::ExecuteScript(nsIScriptContext * aContext, const nsString& aScript) -{ - if (nsnull != aContext) { - const char* url = ""; - PRBool isUndefined = PR_FALSE; - nsAutoString rVal; - -#ifdef APP_DEBUG - char* script_str = aScript.ToNewCString(); - printf("Executing [%s]\n", script_str); - nsCRT::free(script_str); -#endif - - aContext->EvaluateString(aScript, nsnull, nsnull, url, 0, nsnull, rVal, &isUndefined); - } - return NS_OK; -} - NS_IMETHODIMP nsEditorShell::RunUnitTests() { diff --git a/mozilla/editor/composer/src/nsEditorShell.h b/mozilla/editor/composer/src/nsEditorShell.h index be2e58a2701..cf0ac6dd7c9 100644 --- a/mozilla/editor/composer/src/nsEditorShell.h +++ b/mozilla/editor/composer/src/nsEditorShell.h @@ -108,7 +108,6 @@ class nsEditorShell : public nsIEditorShell, nsIPresShell* GetPresShellFor(nsIWebShell* aWebShell); NS_IMETHOD DoEditorMode(nsIWebShell *aWebShell); - NS_IMETHOD ExecuteScript(nsIScriptContext * aContext, const nsString& aScript); NS_IMETHOD InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell); NS_IMETHOD ScrollSelectionIntoView(); NS_IMETHOD TransferDocumentStateListeners(); diff --git a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp index 83ba7ba3d33..16781154dc3 100644 --- a/mozilla/layout/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/layout/xml/document/src/nsXMLContentSink.cpp @@ -1712,12 +1712,17 @@ nsXMLContentSink::EvaluateScript(nsString& aScript, PRUint32 aLineNo, const char rv = docURL->GetSpec(&url); } + nsCOMPtr principal; + if (NS_SUCCEEDED(rv)) { + rv = mDocument->GetPrincipal(getter_AddRefs(principal)); + NS_ASSERTION(principal, "principal required for document"); + } + if (NS_SUCCEEDED(rv)) { nsAutoString val; PRBool isUndefined; - // XXX need principal - (void) context->EvaluateString(aScript, nsnull, nsnull, url, aLineNo, aVersion, + (void) context->EvaluateString(aScript, nsnull, principal, url, aLineNo, aVersion, val, &isUndefined); NS_IF_RELEASE(docURL); diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index 04dbc656ac4..3c740ef9771 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -1975,23 +1975,6 @@ nsBrowserAppCore::FindNext() return rv; } -// XXXbe why is this needed? eliminate -NS_IMETHODIMP -nsBrowserAppCore::ExecuteScript(nsIScriptContext * aContext, const nsString& aScript) -{ - if (nsnull != aContext) { - const char* url = ""; - PRBool isUndefined = PR_FALSE; - nsString rVal; - if (APP_DEBUG) { - printf("Executing [%s]\n", (const char *)nsCAutoString(aScript)); - } - aContext->EvaluateString(aScript, nsnull, nsnull, url, 0, nsnull, rVal, &isUndefined); - } - return NS_OK; -} - - //---------------------------------------------------------------------- diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.h b/mozilla/xpfe/browser/src/nsBrowserInstance.h index 757ce1c2497..84fcbd78fbd 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.h +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.h @@ -83,7 +83,6 @@ class nsBrowserInstance : public nsIBrowserInstance, NS_DECL_NSIURICONTENTLISTENER protected: - NS_IMETHOD ExecuteScript(nsIScriptContext * aContext, const nsString& aScript); nsresult InitializeSearch(nsIFindComponent*); NS_IMETHOD CreateMenuItem(nsIDOMNode * , PRInt32,const PRUnichar * ); NS_IMETHOD UpdateGoMenu();