Bug 1063197 - Callsites of NS_NewInputStreamChannel in /dom/ (r=bz)

This commit is contained in:
Christoph Kerschbaumer 2014-10-16 11:14:52 -07:00
parent 554d4eeea3
commit 537363113b
2 changed files with 25 additions and 4 deletions

View File

@ -22,6 +22,7 @@
#include "nsCRTGlue.h"
#include "nsAutoPtr.h"
#include "nsIScriptSecurityManager.h"
#include "nsNullPrincipal.h"
#include "mozilla/Maybe.h"
#include <algorithm>
@ -409,9 +410,19 @@ nsJSON::DecodeInternal(JSContext* cx,
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv =
NS_NewInputStreamChannel(getter_AddRefs(jsonChannel), mURI, aStream,
nsresult rv;
nsCOMPtr<nsIPrincipal> nullPrincipal =
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewInputStreamChannel(getter_AddRefs(jsonChannel),
mURI,
aStream,
nullPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("application/json"));
if (!jsonChannel || NS_FAILED(rv))
return NS_ERROR_FAILURE;

View File

@ -36,6 +36,7 @@
#include "nsIContentViewer.h"
#include "nsIXPConnect.h"
#include "nsContentUtils.h"
#include "nsNullPrincipal.h"
#include "nsJSUtils.h"
#include "nsThreadUtils.h"
#include "nsIScriptChannel.h"
@ -427,9 +428,18 @@ nsresult nsJSChannel::Init(nsIURI *aURI)
// and the underlying Input Stream will not be created...
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsIPrincipal> nullPrincipal =
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
// If the resultant script evaluation actually does return a value, we
// treat it as html.
rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, mIOThunk,
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
aURI,
mIOThunk,
nullPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER,
NS_LITERAL_CSTRING("text/html"));
if (NS_FAILED(rv)) return rv;