mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 965413 part 10. Use a LoadInfo for loading documents in various places where we force a particular principal. r=smaug
This commit is contained in:
parent
321102201e
commit
22cec45b71
@ -15,6 +15,7 @@
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsError.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
@ -241,8 +242,11 @@ DOMParser::ParseFromStream(nsIInputStream *stream,
|
||||
nsDependentCString(contentType), nullptr);
|
||||
NS_ENSURE_STATE(parserChannel);
|
||||
|
||||
// More principal-faking here
|
||||
parserChannel->SetOwner(mOriginalPrincipal);
|
||||
// More principal-faking here
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(mOriginalPrincipal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
parserChannel->SetLoadInfo(loadInfo);
|
||||
|
||||
if (charset) {
|
||||
parserChannel->SetContentCharset(nsDependentCString(charset));
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/DOMEventTargetHelper.h"
|
||||
#include "mozilla/dom/EventSourceBinding.h"
|
||||
#include "mozilla/dom/MessageEvent.h"
|
||||
@ -375,7 +376,10 @@ EventSource::OnStartRequest(nsIRequest *aRequest,
|
||||
principal = do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
rv = httpChannel->SetOwner(principal);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(principal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
rv = httpChannel->SetLoadInfo(loadInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
|
@ -15,8 +15,10 @@
|
||||
#include "mozilla/dom/MediaSource.h"
|
||||
#include "nsIMemoryReporter.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
|
||||
using mozilla::dom::DOMFileImpl;
|
||||
using mozilla::LoadInfo;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Hash table
|
||||
@ -506,8 +508,6 @@ nsHostObjectProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
stream);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupports> owner = do_QueryInterface(info->mPrincipal);
|
||||
|
||||
nsString type;
|
||||
rv = blob->GetType(type);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -523,7 +523,10 @@ nsHostObjectProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
rv = blob->GetSize(&size);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
channel->SetOwner(owner);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(info->mPrincipal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
channel->SetOriginalURI(uri);
|
||||
channel->SetContentType(NS_ConvertUTF16toUTF8(type));
|
||||
channel->SetContentLength(size);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "mozilla/dom/XMLHttpRequestUploadBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/EventListenerManager.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsDOMBlobBuilder.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
@ -1973,7 +1974,10 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||
documentPrincipal = mPrincipal;
|
||||
}
|
||||
|
||||
channel->SetOwner(documentPrincipal);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(documentPrincipal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
|
||||
nsresult status;
|
||||
request->GetStatus(&status);
|
||||
|
@ -83,6 +83,7 @@
|
||||
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/dom/FallbackEncoding.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "nsIEditingSession.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
@ -1525,7 +1526,10 @@ nsHTMLDocument::Open(JSContext* cx,
|
||||
|
||||
// Set the caller principal, if any, on the channel so that we'll
|
||||
// make sure to use it when we reset.
|
||||
rv = channel->SetOwner(callerPrincipal);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(callerPrincipal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
rv = channel->SetLoadInfo(loadInfo);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -2388,7 +2392,10 @@ nsHTMLDocument::CreateAndAddWyciwygChannel(void)
|
||||
GetDocumentCharacterSet());
|
||||
|
||||
// Use our new principal
|
||||
channel->SetOwner(NodePrincipal());
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(NodePrincipal(), LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
|
||||
// Inherit load flags from the original document's channel
|
||||
channel->SetLoadFlags(mLoadFlags);
|
||||
|
@ -89,6 +89,7 @@
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
#include "mozilla/dom/XULDocumentBinding.h"
|
||||
#include "mozilla/EventDispatcher.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "nsJSUtils.h"
|
||||
@ -2829,7 +2830,10 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
|
||||
// that the overlay's JSObjects etc end up being created
|
||||
// with the right principal and in the correct
|
||||
// compartment.
|
||||
channel->SetOwner(NodePrincipal());
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(NodePrincipal(), LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
|
||||
rv = channel->AsyncOpen(listener, nullptr);
|
||||
}
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "nsIWritablePropertyBag2.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsPluginStreamListenerPeer.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#include "nsEnumeratorUtils.h"
|
||||
@ -2851,7 +2852,10 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
|
||||
|
||||
if (doc) {
|
||||
// Set the owner of channel to the document principal...
|
||||
channel->SetOwner(doc->NodePrincipal());
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(doc->NodePrincipal(), LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
|
||||
// And if it's a script allow it to execute against the
|
||||
// document's script context.
|
||||
|
@ -7,6 +7,9 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
|
||||
using mozilla::LoadInfo;
|
||||
|
||||
/**
|
||||
* URIUtils
|
||||
@ -62,7 +65,10 @@ URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
|
||||
loadGroup))) {
|
||||
return;
|
||||
}
|
||||
channel->SetOwner(sourcePrincipal);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(sourcePrincipal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
}
|
||||
aNewDoc->Reset(channel, loadGroup);
|
||||
aNewDoc->SetPrincipal(sourcePrincipal);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/LoadInfo.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsHostObjectProtocolHandler.h"
|
||||
@ -371,7 +372,10 @@ gfxSVGGlyphsDocument::ParseDocument(const uint8_t *aBuffer, uint32_t aBufLen)
|
||||
SVG_CONTENT_TYPE, UTF8_CHARSET);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
channel->SetOwner(principal);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new LoadInfo(principal, LoadInfo::eInheritPrincipal,
|
||||
LoadInfo::eNotSandboxed);
|
||||
channel->SetLoadInfo(loadInfo);
|
||||
|
||||
// Set this early because various decisions during page-load depend on it.
|
||||
document->SetIsBeingUsedAsImage();
|
||||
|
@ -598,9 +598,9 @@ WyciwygChannelChild::AsyncOpen(nsIStreamListener *aListener, nsISupports *aConte
|
||||
|
||||
// The only places creating wyciwyg: channels should be
|
||||
// HTMLDocument::OpenCommon and session history. Both should be setting an
|
||||
// owner.
|
||||
NS_PRECONDITION(mOwner, "Must have a principal");
|
||||
NS_ENSURE_STATE(mOwner);
|
||||
// owner or loadinfo.
|
||||
NS_PRECONDITION(mOwner || mLoadInfo, "Must have a principal");
|
||||
NS_ENSURE_STATE(mOwner || mLoadInfo);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aListener);
|
||||
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
|
||||
|
Loading…
Reference in New Issue
Block a user