mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 01:10:22 +00:00
Added intersection of principals when multiple scripts are encountered. r=norris
(this is mstoltz's checkin)
This commit is contained in:
parent
0ac075877f
commit
a4082ab0c1
@ -371,7 +371,8 @@ public:
|
||||
nsresult EvaluateScript(nsString& aScript,
|
||||
nsIURI *aScriptURI,
|
||||
PRInt32 aLineNo,
|
||||
const char* aVersion);
|
||||
const char* aVersion,
|
||||
nsIPrincipal* aPrincipal);
|
||||
const char* mScriptLanguageVersion;
|
||||
|
||||
void UpdateAllContexts();
|
||||
@ -4120,9 +4121,11 @@ nsresult
|
||||
HTMLContentSink::EvaluateScript(nsString& aScript,
|
||||
nsIURI *aScriptURI,
|
||||
PRInt32 aLineNo,
|
||||
const char* aVersion)
|
||||
const char* aVersion,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(aPrincipal, "principal required for document");
|
||||
|
||||
if (aScript.Length() > 0) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
@ -4133,11 +4136,6 @@ HTMLContentSink::EvaluateScript(nsString& aScript,
|
||||
NS_ENSURE_SUCCESS(globalObject->GetContext(getter_AddRefs(context)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = mDocument->GetPrincipal(getter_AddRefs(principal));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "principal expected for document");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString ret;
|
||||
char* url = nsnull;
|
||||
|
||||
@ -4146,7 +4144,7 @@ HTMLContentSink::EvaluateScript(nsString& aScript,
|
||||
}
|
||||
|
||||
PRBool isUndefined;
|
||||
context->EvaluateString(aScript, nsnull, principal, url,
|
||||
context->EvaluateString(aScript, nsnull, aPrincipal, url,
|
||||
aLineNo, aVersion, ret, &isUndefined);
|
||||
|
||||
if (url) {
|
||||
@ -4170,7 +4168,24 @@ HTMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||
if (NS_OK == aStatus) {
|
||||
PRBool bodyPresent = PreEvaluateScript();
|
||||
|
||||
rv = EvaluateScript(aData, mScriptURI, 1, mScriptLanguageVersion);
|
||||
nsISupports* owner;
|
||||
aLoader->GetOwner(&owner);
|
||||
nsIPrincipal* prin = nsnull;
|
||||
if (owner)
|
||||
{
|
||||
rv = owner->QueryInterface(NS_GET_IID(nsIPrincipal),
|
||||
(void**)&prin);
|
||||
NS_RELEASE(owner);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mDocument->UpdatePrincipal(&prin);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_IF_RELEASE(prin);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = EvaluateScript(aData, mScriptURI, 1, mScriptLanguageVersion, prin);
|
||||
NS_IF_RELEASE(prin);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PostEvaluateScript(bodyPresent);
|
||||
@ -4335,14 +4350,16 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIPrincipal> prin;
|
||||
mDocument->GetPrincipal(getter_AddRefs(prin));
|
||||
|
||||
PRBool bodyPresent = PreEvaluateScript();
|
||||
|
||||
PRUint32 lineNo = (PRUint32)aNode.GetSourceLineNumber();
|
||||
nsIURI *docURI = mDocument->GetDocumentURL();
|
||||
|
||||
EvaluateScript(script, docURI, lineNo, jsVersionString);
|
||||
if (docURI)
|
||||
NS_RELEASE(docURI);
|
||||
EvaluateScript(script, docURI, lineNo, jsVersionString, prin);
|
||||
NS_IF_RELEASE(docURI);
|
||||
|
||||
PostEvaluateScript(bodyPresent);
|
||||
|
||||
|
@ -966,7 +966,6 @@ nsHTMLFrameInnerFrame::ReloadURL()
|
||||
TempMakeAbsURL(content, url, absURL);
|
||||
|
||||
// Get the referrer from the currently executing script, if any.
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
|
||||
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -966,7 +966,6 @@ nsHTMLFrameInnerFrame::ReloadURL()
|
||||
TempMakeAbsURL(content, url, absURL);
|
||||
|
||||
// Get the referrer from the currently executing script, if any.
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, secMan,
|
||||
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -371,7 +371,8 @@ public:
|
||||
nsresult EvaluateScript(nsString& aScript,
|
||||
nsIURI *aScriptURI,
|
||||
PRInt32 aLineNo,
|
||||
const char* aVersion);
|
||||
const char* aVersion,
|
||||
nsIPrincipal* aPrincipal);
|
||||
const char* mScriptLanguageVersion;
|
||||
|
||||
void UpdateAllContexts();
|
||||
@ -4120,9 +4121,11 @@ nsresult
|
||||
HTMLContentSink::EvaluateScript(nsString& aScript,
|
||||
nsIURI *aScriptURI,
|
||||
PRInt32 aLineNo,
|
||||
const char* aVersion)
|
||||
const char* aVersion,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ASSERTION(aPrincipal, "principal required for document");
|
||||
|
||||
if (aScript.Length() > 0) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
@ -4133,11 +4136,6 @@ HTMLContentSink::EvaluateScript(nsString& aScript,
|
||||
NS_ENSURE_SUCCESS(globalObject->GetContext(getter_AddRefs(context)),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
rv = mDocument->GetPrincipal(getter_AddRefs(principal));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "principal expected for document");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsAutoString ret;
|
||||
char* url = nsnull;
|
||||
|
||||
@ -4146,7 +4144,7 @@ HTMLContentSink::EvaluateScript(nsString& aScript,
|
||||
}
|
||||
|
||||
PRBool isUndefined;
|
||||
context->EvaluateString(aScript, nsnull, principal, url,
|
||||
context->EvaluateString(aScript, nsnull, aPrincipal, url,
|
||||
aLineNo, aVersion, ret, &isUndefined);
|
||||
|
||||
if (url) {
|
||||
@ -4170,7 +4168,24 @@ HTMLContentSink::OnStreamComplete(nsIStreamLoader* aLoader,
|
||||
if (NS_OK == aStatus) {
|
||||
PRBool bodyPresent = PreEvaluateScript();
|
||||
|
||||
rv = EvaluateScript(aData, mScriptURI, 1, mScriptLanguageVersion);
|
||||
nsISupports* owner;
|
||||
aLoader->GetOwner(&owner);
|
||||
nsIPrincipal* prin = nsnull;
|
||||
if (owner)
|
||||
{
|
||||
rv = owner->QueryInterface(NS_GET_IID(nsIPrincipal),
|
||||
(void**)&prin);
|
||||
NS_RELEASE(owner);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mDocument->UpdatePrincipal(&prin);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_IF_RELEASE(prin);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = EvaluateScript(aData, mScriptURI, 1, mScriptLanguageVersion, prin);
|
||||
NS_IF_RELEASE(prin);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PostEvaluateScript(bodyPresent);
|
||||
@ -4335,14 +4350,16 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIPrincipal> prin;
|
||||
mDocument->GetPrincipal(getter_AddRefs(prin));
|
||||
|
||||
PRBool bodyPresent = PreEvaluateScript();
|
||||
|
||||
PRUint32 lineNo = (PRUint32)aNode.GetSourceLineNumber();
|
||||
nsIURI *docURI = mDocument->GetDocumentURL();
|
||||
|
||||
EvaluateScript(script, docURI, lineNo, jsVersionString);
|
||||
if (docURI)
|
||||
NS_RELEASE(docURI);
|
||||
EvaluateScript(script, docURI, lineNo, jsVersionString, prin);
|
||||
NS_IF_RELEASE(docURI);
|
||||
|
||||
PostEvaluateScript(bodyPresent);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user