Fixing bug 415324. Don't change principals on documents during document.load() now that document principals must remain unchanged. r=jonas@sicking.cc, sr=bzbarsky@mit.edu

This commit is contained in:
jst@mozilla.org 2008-03-11 16:47:23 -07:00
parent 2f4360eecd
commit ac13f0ce0c

View File

@ -296,13 +296,6 @@ nsXMLDocument::OnChannelRedirect(nsIChannel *aOldChannel,
return rv;
}
// XXXbz Shouldn't we look at the owner on the new channel at some point?
// It's not gonna be right here, but eventually it will....
nsCOMPtr<nsIPrincipal> principal;
rv = secMan->GetCodebasePrincipal(newLocation, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
SetPrincipal(principal);
return NS_OK;
}
@ -368,8 +361,9 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
return rv;
}
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
nsCOMPtr<nsIURI> codebase;
NodePrincipal()->GetURI(getter_AddRefs(codebase));
principal->GetURI(getter_AddRefs(codebase));
// Get security manager, check to see whether the current document
// is allowed to load this URI. It's important to use the current
@ -413,7 +407,6 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
// be loaded. Note that we need to hold a strong ref to |principal|
// here, because ResetToURI will null out our node principal before
// setting the new one.
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
nsCOMPtr<nsIEventListenerManager> elm(mListenerManager);
mListenerManager = nsnull;
@ -441,23 +434,6 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
return rv;
}
// Set a principal for this document
// XXXbz StartDocumentLoad should handle that.... And we shouldn't be calling
// StartDocumentLoad until we get an OnStartRequest from this channel!
nsCOMPtr<nsISupports> channelOwner;
rv = channel->GetOwner(getter_AddRefs(channelOwner));
// We don't care if GetOwner() succeeded here, if it failed,
// channelOwner will be null, which is what we want in that case.
principal = do_QueryInterface(channelOwner);
if (NS_FAILED(rv) || !principal) {
rv = secMan->GetCodebasePrincipal(uri, getter_AddRefs(principal));
NS_ENSURE_TRUE(principal, rv);
}
SetPrincipal(principal);
// Prepare for loading the XML document "into oneself"
nsCOMPtr<nsIStreamListener> listener;
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,