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
Родитель 736f4fe843
Коммит 123a96d191
1 изменённых файлов: 2 добавлений и 26 удалений

Просмотреть файл

@ -296,13 +296,6 @@ nsXMLDocument::OnChannelRedirect(nsIChannel *aOldChannel,
return rv; 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; return NS_OK;
} }
@ -368,8 +361,9 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
return rv; return rv;
} }
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
nsCOMPtr<nsIURI> codebase; nsCOMPtr<nsIURI> codebase;
NodePrincipal()->GetURI(getter_AddRefs(codebase)); principal->GetURI(getter_AddRefs(codebase));
// Get security manager, check to see whether the current document // Get security manager, check to see whether the current document
// is allowed to load this URI. It's important to use the current // 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| // be loaded. Note that we need to hold a strong ref to |principal|
// here, because ResetToURI will null out our node principal before // here, because ResetToURI will null out our node principal before
// setting the new one. // setting the new one.
nsCOMPtr<nsIPrincipal> principal = NodePrincipal();
nsCOMPtr<nsIEventListenerManager> elm(mListenerManager); nsCOMPtr<nsIEventListenerManager> elm(mListenerManager);
mListenerManager = nsnull; mListenerManager = nsnull;
@ -441,23 +434,6 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
return rv; 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" // Prepare for loading the XML document "into oneself"
nsCOMPtr<nsIStreamListener> listener; nsCOMPtr<nsIStreamListener> listener;
if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel, if (NS_FAILED(rv = StartDocumentLoad(kLoadAsData, channel,