mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 03:19:06 +00:00
Bug 1872839 - Remove aMimeTypeGuess parameter from nsIContentPolicy. r=freddyb
Differential Revision: https://phabricator.services.mozilla.com/D197794
This commit is contained in:
parent
1ed5ce239c
commit
346cecd51c
@ -2735,7 +2735,7 @@ function blockAboutPage(manager, feature, neededOnContentProcess = false) {
|
||||
}
|
||||
|
||||
let ChromeURLBlockPolicy = {
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
let contentType = loadInfo.externalContentPolicyType;
|
||||
if (
|
||||
(contentLocation.scheme != "chrome" &&
|
||||
@ -2755,7 +2755,7 @@ let ChromeURLBlockPolicy = {
|
||||
}
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
classDescription: "Policy Engine Content Policy",
|
||||
|
@ -105,7 +105,7 @@ export let WebsiteFilter = {
|
||||
Services.obs.addObserver(this, "http-on-examine-response", true);
|
||||
},
|
||||
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
let contentType = loadInfo.externalContentPolicyType;
|
||||
let url = contentLocation.spec;
|
||||
if (contentLocation.scheme == "view-source") {
|
||||
@ -130,7 +130,7 @@ export let WebsiteFilter = {
|
||||
}
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
observe(subject, topic, data) {
|
||||
|
@ -8397,7 +8397,6 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(aLoadState->URI(), secCheckLoadInfo,
|
||||
""_ns, // mime guess
|
||||
&shouldLoad);
|
||||
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
|
@ -50,7 +50,7 @@ var policy = {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
let contentType = loadInfo.externalContentPolicyType;
|
||||
let context = loadInfo.loadingContext;
|
||||
|
||||
@ -78,7 +78,7 @@ var policy = {
|
||||
return Ci.nsIContentPolicy.REJECT_REQUEST;
|
||||
},
|
||||
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
};
|
||||
|
@ -63,7 +63,6 @@ nsContentPolicy::~nsContentPolicy() = default;
|
||||
inline nsresult nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
nsIURI* contentLocation,
|
||||
nsILoadInfo* loadInfo,
|
||||
const nsACString& mimeType,
|
||||
int16_t* decision) {
|
||||
nsCOMPtr<nsISupports> requestingContext = loadInfo->GetLoadingContext();
|
||||
// sanity-check passed-through parameters
|
||||
@ -105,8 +104,7 @@ inline nsresult nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
int32_t count = entries.Count();
|
||||
for (int32_t i = 0; i < count; i++) {
|
||||
/* check the appropriate policy */
|
||||
rv = (entries[i]->*policyMethod)(contentLocation, loadInfo, mimeType,
|
||||
decision);
|
||||
rv = (entries[i]->*policyMethod)(contentLocation, loadInfo, decision);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && NS_CP_REJECTED(*decision)) {
|
||||
/* policy says no, no point continuing to check */
|
||||
@ -141,11 +139,11 @@ inline nsresult nsContentPolicy::CheckPolicy(CPMethod policyMethod,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldLoad(nsIURI* contentLocation, nsILoadInfo* loadInfo,
|
||||
const nsACString& mimeType, int16_t* decision) {
|
||||
int16_t* decision) {
|
||||
// ShouldProcess does not need a content location, but we do
|
||||
MOZ_ASSERT(contentLocation, "Must provide request location");
|
||||
nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldLoad, contentLocation,
|
||||
loadInfo, mimeType, decision);
|
||||
loadInfo, decision);
|
||||
LOG_CHECK("ShouldLoad");
|
||||
|
||||
return rv;
|
||||
@ -153,9 +151,9 @@ nsContentPolicy::ShouldLoad(nsIURI* contentLocation, nsILoadInfo* loadInfo,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsContentPolicy::ShouldProcess(nsIURI* contentLocation, nsILoadInfo* loadInfo,
|
||||
const nsACString& mimeType, int16_t* decision) {
|
||||
int16_t* decision) {
|
||||
nsresult rv = CheckPolicy(&nsIContentPolicy::ShouldProcess, contentLocation,
|
||||
loadInfo, mimeType, decision);
|
||||
loadInfo, decision);
|
||||
LOG_CHECK("ShouldProcess");
|
||||
|
||||
return rv;
|
||||
|
@ -34,8 +34,7 @@ class nsContentPolicy : public nsIContentPolicy {
|
||||
// Helper method that applies policyMethod across all policies in mPolicies
|
||||
// with the given parameters
|
||||
nsresult CheckPolicy(CPMethod policyMethod, nsIURI* aURI,
|
||||
nsILoadInfo* aLoadInfo, const nsACString& mimeGuess,
|
||||
int16_t* decision);
|
||||
nsILoadInfo* aLoadInfo, int16_t* decision);
|
||||
};
|
||||
|
||||
nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
|
||||
|
@ -163,19 +163,19 @@ inline const char* NS_CP_ContentTypeName(ExtContentPolicyType contentType) {
|
||||
}
|
||||
|
||||
/* Passes on parameters from its "caller"'s context. */
|
||||
#define CHECK_CONTENT_POLICY(action) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsCOMPtr<nsIContentPolicy> policy = \
|
||||
do_GetService(NS_CONTENTPOLICY_CONTRACTID); \
|
||||
if (!policy) return NS_ERROR_FAILURE; \
|
||||
\
|
||||
return policy->action(contentLocation, loadInfo, mimeType, decision); \
|
||||
#define CHECK_CONTENT_POLICY(action) \
|
||||
PR_BEGIN_MACRO \
|
||||
nsCOMPtr<nsIContentPolicy> policy = \
|
||||
do_GetService(NS_CONTENTPOLICY_CONTRACTID); \
|
||||
if (!policy) return NS_ERROR_FAILURE; \
|
||||
\
|
||||
return policy->action(contentLocation, loadInfo, decision); \
|
||||
PR_END_MACRO
|
||||
|
||||
/* Passes on parameters from its "caller"'s context. */
|
||||
#define CHECK_CONTENT_POLICY_WITH_SERVICE(action, _policy) \
|
||||
PR_BEGIN_MACRO \
|
||||
return _policy->action(contentLocation, loadInfo, mimeType, decision); \
|
||||
#define CHECK_CONTENT_POLICY_WITH_SERVICE(action, _policy) \
|
||||
PR_BEGIN_MACRO \
|
||||
return _policy->action(contentLocation, loadInfo, decision); \
|
||||
PR_END_MACRO
|
||||
|
||||
/**
|
||||
@ -184,40 +184,40 @@ inline const char* NS_CP_ContentTypeName(ExtContentPolicyType contentType) {
|
||||
*
|
||||
* Note: requestOrigin is scoped outside the PR_BEGIN_MACRO/PR_END_MACRO on
|
||||
* purpose */
|
||||
#define CHECK_PRINCIPAL_CSP_AND_DATA(action) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (loadingPrincipal && loadingPrincipal->IsSystemPrincipal()) { \
|
||||
/* We exempt most loads into any document with the system principal \
|
||||
* from content policy (except CSP) checks, mostly as an optimization. \
|
||||
* Which means that we need to apply this check to the loading principal, \
|
||||
* not the principal that triggered the load. */ \
|
||||
/* Check CSP for System Privileged pages */ \
|
||||
CSPService::ConsultCSP(contentLocation, loadInfo, mimeType, decision); \
|
||||
if (NS_CP_REJECTED(*decision)) { \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (contentType != nsIContentPolicy::TYPE_DOCUMENT && \
|
||||
contentType != nsIContentPolicy::TYPE_UA_FONT) { \
|
||||
*decision = nsIContentPolicy::ACCEPT; \
|
||||
nsCOMPtr<nsINode> n = do_QueryInterface(context); \
|
||||
if (!n) { \
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = do_QueryInterface(context); \
|
||||
n = win ? win->GetExtantDoc() : nullptr; \
|
||||
} \
|
||||
if (n) { \
|
||||
mozilla::dom::Document* d = n->OwnerDoc(); \
|
||||
if (d->IsLoadedAsData() || d->IsBeingUsedAsImage() || \
|
||||
d->IsResourceDoc()) { \
|
||||
nsCOMPtr<nsIContentPolicy> dataPolicy = \
|
||||
do_GetService("@mozilla.org/data-document-content-policy;1"); \
|
||||
if (dataPolicy) { \
|
||||
dataPolicy->action(contentLocation, loadInfo, mimeType, decision); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
#define CHECK_PRINCIPAL_CSP_AND_DATA(action) \
|
||||
PR_BEGIN_MACRO \
|
||||
if (loadingPrincipal && loadingPrincipal->IsSystemPrincipal()) { \
|
||||
/* We exempt most loads into any document with the system principal \
|
||||
* from content policy (except CSP) checks, mostly as an optimization. \
|
||||
* Which means that we need to apply this check to the loading principal, \
|
||||
* not the principal that triggered the load. */ \
|
||||
/* Check CSP for System Privileged pages */ \
|
||||
CSPService::ConsultCSP(contentLocation, loadInfo, decision); \
|
||||
if (NS_CP_REJECTED(*decision)) { \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (contentType != nsIContentPolicy::TYPE_DOCUMENT && \
|
||||
contentType != nsIContentPolicy::TYPE_UA_FONT) { \
|
||||
*decision = nsIContentPolicy::ACCEPT; \
|
||||
nsCOMPtr<nsINode> n = do_QueryInterface(context); \
|
||||
if (!n) { \
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win = do_QueryInterface(context); \
|
||||
n = win ? win->GetExtantDoc() : nullptr; \
|
||||
} \
|
||||
if (n) { \
|
||||
mozilla::dom::Document* d = n->OwnerDoc(); \
|
||||
if (d->IsLoadedAsData() || d->IsBeingUsedAsImage() || \
|
||||
d->IsResourceDoc()) { \
|
||||
nsCOMPtr<nsIContentPolicy> dataPolicy = \
|
||||
do_GetService("@mozilla.org/data-document-content-policy;1"); \
|
||||
if (dataPolicy) { \
|
||||
dataPolicy->action(contentLocation, loadInfo, decision); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
return NS_OK; \
|
||||
} \
|
||||
PR_END_MACRO
|
||||
|
||||
/**
|
||||
@ -231,8 +231,8 @@ inline const char* NS_CP_ContentTypeName(ExtContentPolicyType contentType) {
|
||||
* origin URI will be passed).
|
||||
*/
|
||||
inline nsresult NS_CheckContentLoadPolicy(
|
||||
nsIURI* contentLocation, nsILoadInfo* loadInfo, const nsACString& mimeType,
|
||||
int16_t* decision, nsIContentPolicy* policyService = nullptr) {
|
||||
nsIURI* contentLocation, nsILoadInfo* loadInfo, int16_t* decision,
|
||||
nsIContentPolicy* policyService = nullptr) {
|
||||
nsIPrincipal* loadingPrincipal = loadInfo->GetLoadingPrincipal();
|
||||
nsCOMPtr<nsISupports> context = loadInfo->GetLoadingContext();
|
||||
nsContentPolicyType contentType = loadInfo->InternalContentPolicyType();
|
||||
@ -247,8 +247,8 @@ inline nsresult NS_CheckContentLoadPolicy(
|
||||
* Alias for calling ShouldProcess on the content policy service.
|
||||
*/
|
||||
inline nsresult NS_CheckContentProcessPolicy(
|
||||
nsIURI* contentLocation, nsILoadInfo* loadInfo, const nsACString& mimeType,
|
||||
int16_t* decision, nsIContentPolicy* policyService = nullptr) {
|
||||
nsIURI* contentLocation, nsILoadInfo* loadInfo, int16_t* decision,
|
||||
nsIContentPolicy* policyService = nullptr) {
|
||||
nsIPrincipal* loadingPrincipal = loadInfo->GetLoadingPrincipal();
|
||||
nsCOMPtr<nsISupports> context = loadInfo->GetLoadingContext();
|
||||
nsContentPolicyType contentType = loadInfo->InternalContentPolicyType();
|
||||
|
@ -3899,9 +3899,8 @@ bool nsContentUtils::CanLoadImage(nsIURI* aURI, nsINode* aNode,
|
||||
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
|
||||
rv = NS_CheckContentLoadPolicy(aURI, secCheckLoadInfo,
|
||||
""_ns, // mime guess
|
||||
&decision, GetContentPolicy());
|
||||
rv = NS_CheckContentLoadPolicy(aURI, secCheckLoadInfo, &decision,
|
||||
GetContentPolicy());
|
||||
|
||||
return NS_SUCCEEDED(rv) && NS_CP_ACCEPTED(decision);
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ static bool HasFlags(nsIURI* aURI, uint32_t aURIFlags) {
|
||||
NS_IMETHODIMP
|
||||
nsDataDocumentContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aDecision) {
|
||||
auto setBlockingReason = mozilla::MakeScopeExit([&]() {
|
||||
if (NS_CP_REJECTED(*aDecision)) {
|
||||
@ -171,7 +170,6 @@ nsDataDocumentContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
||||
NS_IMETHODIMP
|
||||
nsDataDocumentContentPolicy::ShouldProcess(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aDecision) {
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aMimeGuess, aDecision);
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aDecision);
|
||||
}
|
||||
|
@ -39,19 +39,6 @@ interface nsIContentPolicy : nsISupports
|
||||
* But if you are fairly sure that no one would care about your more specific
|
||||
* type, then it's ok to use TYPE_OTHER.
|
||||
*
|
||||
* Extension developers: Whenever it is reasonable, use one of the existing
|
||||
* content types. If none of the existing content types are right for
|
||||
* something you are doing, file a bug in the Core/DOM component that
|
||||
* includes a patch that adds your new content type to the end of the list of
|
||||
* TYPE_* constants here. But, don't start using your new content type until
|
||||
* your patch has been accepted, because it will be uncertain what exact
|
||||
* value and name your new content type will have; in that interim period,
|
||||
* use TYPE_OTHER. In your patch, document your new content type in the style
|
||||
* of the existing ones. In the bug you file, provide a more detailed
|
||||
* description of the new type of content you want Gecko to support, so that
|
||||
* the existing implementations of nsIContentPolicy can be properly modified
|
||||
* to deal with that new type of content.
|
||||
*
|
||||
* Implementations of nsIContentPolicy should treat this the same way they
|
||||
* treat unknown types, because existing users of TYPE_OTHER may be converted
|
||||
* to use new content types.
|
||||
@ -525,12 +512,6 @@ interface nsIContentPolicy : nsISupports
|
||||
*
|
||||
* @param aLoadInfo the loadinfo of the channel being evaluated.
|
||||
*
|
||||
* @param aMimeTypeGuess OPTIONAL. a guess for the requested content's
|
||||
* MIME type, based on information available to
|
||||
* the request initiator (e.g., an OBJECT's type
|
||||
* attribute); does not reliably reflect the
|
||||
* actual MIME type of the requested content
|
||||
*
|
||||
* @return ACCEPT or REJECT_*
|
||||
*
|
||||
* @note shouldLoad can be called while the DOM and layout of the document
|
||||
@ -551,8 +532,7 @@ interface nsIContentPolicy : nsISupports
|
||||
* above, do them off timeout or event.
|
||||
*/
|
||||
short shouldLoad(in nsIURI aContentLocation,
|
||||
in nsILoadInfo aLoadInfo,
|
||||
in ACString aMimeTypeGuess);
|
||||
in nsILoadInfo aLoadInfo);
|
||||
|
||||
/**
|
||||
* Should the resource be processed?
|
||||
@ -566,11 +546,6 @@ interface nsIContentPolicy : nsISupports
|
||||
*
|
||||
* @param aLoadInfo the loadinfo of the channel being evaluated.
|
||||
*
|
||||
* @param aMimeType the MIME type of the requested resource (e.g.,
|
||||
* image/png), as reported by the networking library,
|
||||
* if available (may be empty if inappropriate for
|
||||
* the type).
|
||||
*
|
||||
* @return ACCEPT or REJECT_*
|
||||
*
|
||||
* @note shouldProcess can be called while the DOM and layout of the document
|
||||
@ -578,8 +553,7 @@ interface nsIContentPolicy : nsISupports
|
||||
* what this means for implementors of this method.
|
||||
*/
|
||||
short shouldProcess(in nsIURI aContentLocation,
|
||||
in nsILoadInfo aLoadInfo,
|
||||
in ACString aMimeType);
|
||||
in nsILoadInfo aLoadInfo);
|
||||
};
|
||||
|
||||
typedef nsIContentPolicy_nsContentPolicyType nsContentPolicyType;
|
||||
|
@ -22,7 +22,6 @@ NS_IMPL_ISUPPORTS(nsNoDataProtocolContentPolicy, nsIContentPolicy)
|
||||
NS_IMETHODIMP
|
||||
nsNoDataProtocolContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aDecision) {
|
||||
ExtContentPolicyType contentType = aLoadInfo->GetExternalContentPolicyType();
|
||||
|
||||
@ -60,7 +59,6 @@ nsNoDataProtocolContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
||||
NS_IMETHODIMP
|
||||
nsNoDataProtocolContentPolicy::ShouldProcess(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aDecision) {
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aMimeGuess, aDecision);
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aDecision);
|
||||
}
|
||||
|
@ -806,9 +806,9 @@ bool nsObjectLoadingContent::CheckLoadPolicy(int16_t* aContentPolicy) {
|
||||
contentPolicyType);
|
||||
|
||||
*aContentPolicy = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(mURI, secCheckLoadInfo, mContentType,
|
||||
aContentPolicy,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(mURI, secCheckLoadInfo, aContentPolicy,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
if (NS_CP_REJECTED(*aContentPolicy)) {
|
||||
LOG(("OBJLC [%p]: Content policy denied load of %s", this,
|
||||
@ -858,7 +858,7 @@ bool nsObjectLoadingContent::CheckProcessPolicy(int16_t* aContentPolicy) {
|
||||
|
||||
*aContentPolicy = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentProcessPolicy(
|
||||
mURI ? mURI : mBaseURI, secCheckLoadInfo, mContentType, aContentPolicy,
|
||||
mURI ? mURI : mBaseURI, secCheckLoadInfo, aContentPolicy,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
|
@ -44,7 +44,7 @@ function createChromeScript() {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
if (contentLocation.asciiSpec === "http://mochi.test:8888/tests/dom/base/test/test_bug375314-2.html/this/is/the/test/url") {
|
||||
sendAsyncMessage("loadBlocked", { policyType: loadInfo.externalContentPolicyType});
|
||||
return Ci.nsIContentPolicy.REJECT_REQUEST;
|
||||
@ -52,7 +52,7 @@ function createChromeScript() {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ var policy = {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
let contentType = loadInfo.externalContentPolicyType;
|
||||
// Remember last content type seen for the test url
|
||||
if (SpecialPowers.wrap(contentLocation).spec == testURL) {
|
||||
@ -57,7 +57,7 @@ var policy = {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ var policy = {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
var url = window.location.href.substr(0, window.location.href.indexOf('test_bug498897'));
|
||||
let loadingPrincipal = loadInfo.loadingPrincipal;
|
||||
if (loadingPrincipal) {
|
||||
@ -58,7 +58,7 @@ var policy = {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
}
|
||||
|
@ -80,9 +80,6 @@ ImageListener::OnStartRequest(nsIRequest* request) {
|
||||
nsCOMPtr<nsIURI> channelURI;
|
||||
channel->GetURI(getter_AddRefs(channelURI));
|
||||
|
||||
nsAutoCString mimeType;
|
||||
channel->GetContentType(mimeType);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
|
||||
// query the corresponding arguments for the channel loadinfo and pass
|
||||
// it on to the temporary loadinfo used for content policy checks.
|
||||
@ -101,9 +98,9 @@ ImageListener::OnStartRequest(nsIRequest* request) {
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE);
|
||||
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentProcessPolicy(
|
||||
channelURI, secCheckLoadInfo, mimeType, &decision,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv =
|
||||
NS_CheckContentProcessPolicy(channelURI, secCheckLoadInfo, &decision,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(decision)) {
|
||||
request->Cancel(NS_ERROR_CONTENT_BLOCKED);
|
||||
|
@ -192,7 +192,7 @@ bool ScriptElement::MaybeProcessScript() {
|
||||
}
|
||||
|
||||
RefPtr<ScriptLoader> loader = ownerDoc->ScriptLoader();
|
||||
return loader->ProcessScriptElement(this, type);
|
||||
return loader->ProcessScriptElement(this);
|
||||
}
|
||||
|
||||
bool ScriptElement::GetScriptType(nsAString& aType) {
|
||||
|
@ -406,7 +406,6 @@ nsContentPolicyType ScriptLoadRequestToContentPolicyType(
|
||||
|
||||
nsresult ScriptLoader::CheckContentPolicy(Document* aDocument,
|
||||
nsIScriptElement* aElement,
|
||||
const nsAString& aType,
|
||||
const nsAString& aNonce,
|
||||
ScriptLoadRequest* aRequest) {
|
||||
nsContentPolicyType contentPolicyType =
|
||||
@ -430,9 +429,9 @@ nsresult ScriptLoader::CheckContentPolicy(Document* aDocument,
|
||||
}
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(
|
||||
aRequest->mURI, secCheckLoadInfo, NS_LossyConvertUTF16toASCII(aType),
|
||||
&shouldLoad, nsContentUtils::GetContentPolicy());
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(aRequest->mURI, secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
if (NS_FAILED(rv) || shouldLoad != nsIContentPolicy::REJECT_TYPE) {
|
||||
return NS_ERROR_CONTENT_BLOCKED;
|
||||
@ -1037,8 +1036,7 @@ already_AddRefed<ScriptLoadRequest> ScriptLoader::CreateLoadRequest(
|
||||
return aRequest.forget();
|
||||
}
|
||||
|
||||
bool ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement,
|
||||
const nsAutoString& aTypeAttr) {
|
||||
bool ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement) {
|
||||
// We need a document to evaluate scripts.
|
||||
NS_ENSURE_TRUE(mDocument, false);
|
||||
|
||||
@ -1076,8 +1074,7 @@ bool ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement,
|
||||
|
||||
// Step 15. and later in the HTML5 spec
|
||||
if (aElement->GetScriptExternal()) {
|
||||
return ProcessExternalScript(aElement, scriptKind, aTypeAttr,
|
||||
scriptContent);
|
||||
return ProcessExternalScript(aElement, scriptKind, scriptContent);
|
||||
}
|
||||
|
||||
return ProcessInlineScript(aElement, scriptKind);
|
||||
@ -1091,7 +1088,6 @@ static ParserMetadata GetParserMetadata(nsIScriptElement* aElement) {
|
||||
|
||||
bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
ScriptKind aScriptKind,
|
||||
const nsAutoString& aTypeAttr,
|
||||
nsIContent* aScriptContent) {
|
||||
LOG(("ScriptLoader (%p): Process external script for element %p", this,
|
||||
aElement));
|
||||
@ -1135,8 +1131,8 @@ bool ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
|
||||
RefPtr<ScriptLoadRequest> request =
|
||||
LookupPreloadRequest(aElement, aScriptKind, sriMetadata);
|
||||
|
||||
if (request && NS_FAILED(CheckContentPolicy(mDocument, aElement, aTypeAttr,
|
||||
nonce, request))) {
|
||||
if (request &&
|
||||
NS_FAILED(CheckContentPolicy(mDocument, aElement, nonce, request))) {
|
||||
LOG(("ScriptLoader (%p): content policy check failed for preload", this));
|
||||
|
||||
// Probably plans have changed; even though the preload was allowed seems
|
||||
|
@ -187,8 +187,7 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
* @param aElement The element representing the script to be loaded and
|
||||
* evaluated.
|
||||
*/
|
||||
bool ProcessScriptElement(nsIScriptElement* aElement,
|
||||
const nsAutoString& aTypeAttr);
|
||||
bool ProcessScriptElement(nsIScriptElement* aElement);
|
||||
|
||||
/**
|
||||
* Gets the currently executing script. This is useful if you want to
|
||||
@ -452,7 +451,6 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
void ContinueParserAsync(ScriptLoadRequest* aParserBlockingRequest);
|
||||
|
||||
bool ProcessExternalScript(nsIScriptElement* aElement, ScriptKind aScriptKind,
|
||||
const nsAutoString& aTypeAttr,
|
||||
nsIContent* aScriptContent);
|
||||
|
||||
bool ProcessInlineScript(nsIScriptElement* aElement, ScriptKind aScriptKind);
|
||||
@ -475,7 +473,6 @@ class ScriptLoader final : public JS::loader::ScriptLoaderInterface {
|
||||
*/
|
||||
static nsresult CheckContentPolicy(Document* aDocument,
|
||||
nsIScriptElement* aElement,
|
||||
const nsAString& aType,
|
||||
const nsAString& aNonce,
|
||||
ScriptLoadRequest* aRequest);
|
||||
|
||||
|
@ -104,7 +104,6 @@ bool subjectToCSP(nsIURI* aURI, nsContentPolicyType aContentType) {
|
||||
|
||||
/* static */ nsresult CSPService::ConsultCSP(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeTypeGuess,
|
||||
int16_t* aDecision) {
|
||||
if (!aContentLocation) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -204,13 +203,12 @@ bool subjectToCSP(nsIURI* aURI, nsContentPolicyType aContentType) {
|
||||
/* nsIContentPolicy implementation */
|
||||
NS_IMETHODIMP
|
||||
CSPService::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeTypeGuess, int16_t* aDecision) {
|
||||
return ConsultCSP(aContentLocation, aLoadInfo, aMimeTypeGuess, aDecision);
|
||||
int16_t* aDecision) {
|
||||
return ConsultCSP(aContentLocation, aLoadInfo, aDecision);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CSPService::ShouldProcess(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeTypeGuess,
|
||||
int16_t* aDecision) {
|
||||
if (!aContentLocation) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -236,7 +234,7 @@ CSPService::ShouldProcess(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aMimeTypeGuess, aDecision);
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aDecision);
|
||||
}
|
||||
|
||||
/* nsIChannelEventSink implementation */
|
||||
|
@ -30,7 +30,6 @@ class CSPService : public nsIContentPolicy, public nsIChannelEventSink {
|
||||
// helper function to avoid creating a new instance of the
|
||||
// cspservice everytime we call content policies.
|
||||
static nsresult ConsultCSP(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeTypeGuess,
|
||||
int16_t* aDecision);
|
||||
|
||||
// Static helper to check CSP when doing a channel redirect.
|
||||
|
@ -384,55 +384,12 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
nsILoadInfo* aLoadInfo) {
|
||||
ExtContentPolicyType contentPolicyType =
|
||||
aLoadInfo->GetExternalContentPolicyType();
|
||||
nsContentPolicyType internalContentPolicyType =
|
||||
aLoadInfo->InternalContentPolicyType();
|
||||
nsCString mimeTypeGuess;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
switch (contentPolicyType) {
|
||||
case ExtContentPolicy::TYPE_OTHER: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_SCRIPT: {
|
||||
mimeTypeGuess = "application/javascript"_ns;
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_IMAGE: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_STYLESHEET: {
|
||||
mimeTypeGuess = "text/css"_ns;
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_OBJECT: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_DOCUMENT: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_SUBDOCUMENT: {
|
||||
mimeTypeGuess = "text/html"_ns;
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_PING: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_XMLHTTPREQUEST: {
|
||||
#ifdef DEBUG
|
||||
{
|
||||
@ -441,23 +398,10 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
"type_xml requires requestingContext of type Document");
|
||||
}
|
||||
#endif
|
||||
// We're checking for the external TYPE_XMLHTTPREQUEST here in case
|
||||
// an addon creates a request with that type.
|
||||
if (internalContentPolicyType ==
|
||||
nsIContentPolicy::TYPE_INTERNAL_XMLHTTPREQUEST ||
|
||||
internalContentPolicyType == nsIContentPolicy::TYPE_XMLHTTPREQUEST) {
|
||||
mimeTypeGuess.Truncate();
|
||||
} else {
|
||||
MOZ_ASSERT(internalContentPolicyType ==
|
||||
nsIContentPolicy::TYPE_INTERNAL_EVENTSOURCE,
|
||||
"can not set mime type guess for unexpected internal type");
|
||||
mimeTypeGuess = nsLiteralCString(TEXT_EVENT_STREAM);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_OBJECT_SUBREQUEST: {
|
||||
mimeTypeGuess.Truncate();
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINode> node = aLoadInfo->LoadingNode();
|
||||
@ -470,7 +414,6 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_DTD: {
|
||||
mimeTypeGuess.Truncate();
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINode> node = aLoadInfo->LoadingNode();
|
||||
@ -481,18 +424,7 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_FONT:
|
||||
case ExtContentPolicy::TYPE_UA_FONT: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_MEDIA: {
|
||||
if (internalContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_TRACK) {
|
||||
mimeTypeGuess = "text/vtt"_ns;
|
||||
} else {
|
||||
mimeTypeGuess.Truncate();
|
||||
}
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINode> node = aLoadInfo->LoadingNode();
|
||||
@ -513,17 +445,10 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
rv = httpChannelInternal->GetProxyURI(getter_AddRefs(uri));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
}
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_CSP_REPORT: {
|
||||
mimeTypeGuess.Truncate();
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_XSLT: {
|
||||
mimeTypeGuess = "application/xml"_ns;
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINode> node = aLoadInfo->LoadingNode();
|
||||
@ -535,7 +460,6 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_BEACON: {
|
||||
mimeTypeGuess.Truncate();
|
||||
#ifdef DEBUG
|
||||
{
|
||||
nsCOMPtr<nsINode> node = aLoadInfo->LoadingNode();
|
||||
@ -546,21 +470,26 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_WEB_MANIFEST: {
|
||||
mimeTypeGuess = "application/manifest+json"_ns;
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_OTHER:
|
||||
case ExtContentPolicy::TYPE_SCRIPT:
|
||||
case ExtContentPolicy::TYPE_IMAGE:
|
||||
case ExtContentPolicy::TYPE_STYLESHEET:
|
||||
case ExtContentPolicy::TYPE_OBJECT:
|
||||
case ExtContentPolicy::TYPE_DOCUMENT:
|
||||
case ExtContentPolicy::TYPE_SUBDOCUMENT:
|
||||
case ExtContentPolicy::TYPE_PING:
|
||||
case ExtContentPolicy::TYPE_FONT:
|
||||
case ExtContentPolicy::TYPE_UA_FONT:
|
||||
case ExtContentPolicy::TYPE_CSP_REPORT:
|
||||
case ExtContentPolicy::TYPE_WEB_MANIFEST:
|
||||
case ExtContentPolicy::TYPE_FETCH:
|
||||
case ExtContentPolicy::TYPE_IMAGESET:
|
||||
case ExtContentPolicy::TYPE_SAVEAS_DOWNLOAD:
|
||||
case ExtContentPolicy::TYPE_SPECULATIVE:
|
||||
case ExtContentPolicy::TYPE_PROXIED_WEBRTC_MEDIA:
|
||||
case ExtContentPolicy::TYPE_WEB_TRANSPORT:
|
||||
case ExtContentPolicy::TYPE_WEB_IDENTITY: {
|
||||
mimeTypeGuess.Truncate();
|
||||
case ExtContentPolicy::TYPE_WEB_IDENTITY:
|
||||
break;
|
||||
}
|
||||
|
||||
case ExtContentPolicy::TYPE_INVALID:
|
||||
MOZ_ASSERT(false,
|
||||
@ -569,7 +498,7 @@ static nsresult DoContentSecurityChecks(nsIChannel* aChannel,
|
||||
}
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(uri, aLoadInfo, mimeTypeGuess, &shouldLoad,
|
||||
rv = NS_CheckContentLoadPolicy(uri, aLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
|
@ -1626,7 +1626,6 @@ long nsContentSecurityUtils::ClassifyDownload(
|
||||
nsMixedContentBlocker::ShouldLoad(false, // aHadInsecureImageRedirect
|
||||
contentLocation, // aContentLocation,
|
||||
secCheckLoadInfo, // aLoadinfo
|
||||
aMimeTypeGuess, // aMimeGuess,
|
||||
false, // aReportError
|
||||
&decission // aDecision
|
||||
);
|
||||
|
@ -183,9 +183,7 @@ nsMixedContentBlocker::AsyncOnChannelRedirect(
|
||||
}
|
||||
|
||||
int16_t decision = REJECT_REQUEST;
|
||||
rv = ShouldLoad(newUri, loadInfo,
|
||||
""_ns, // aMimeGuess
|
||||
&decision);
|
||||
rv = ShouldLoad(newUri, loadInfo, &decision);
|
||||
if (NS_FAILED(rv)) {
|
||||
autoCallback.DontCallback();
|
||||
aOldChannel->Cancel(NS_ERROR_DOM_BAD_URI);
|
||||
@ -208,16 +206,13 @@ nsMixedContentBlocker::AsyncOnChannelRedirect(
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsMixedContentBlocker::ShouldLoad(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aDecision) {
|
||||
nsILoadInfo* aLoadInfo, int16_t* aDecision) {
|
||||
// We pass in false as the first parameter to ShouldLoad(), because the
|
||||
// callers of this method don't know whether the load went through cached
|
||||
// image redirects. This is handled by direct callers of the static
|
||||
// ShouldLoad.
|
||||
nsresult rv =
|
||||
ShouldLoad(false, // aHadInsecureImageRedirect
|
||||
aContentLocation, aLoadInfo, aMimeGuess, true, aDecision);
|
||||
nsresult rv = ShouldLoad(false, // aHadInsecureImageRedirect
|
||||
aContentLocation, aLoadInfo, true, aDecision);
|
||||
|
||||
if (*aDecision == nsIContentPolicy::REJECT_REQUEST) {
|
||||
NS_SetRequestBlockingReason(aLoadInfo,
|
||||
@ -425,7 +420,6 @@ static already_AddRefed<nsIURI> GetPrincipalURIOrPrecursorPrincipalURI(
|
||||
nsresult nsMixedContentBlocker::ShouldLoad(bool aHadInsecureImageRedirect,
|
||||
nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
bool aReportError,
|
||||
int16_t* aDecision) {
|
||||
// Asserting that we are on the main thread here and hence do not have to lock
|
||||
@ -1006,7 +1000,6 @@ bool nsMixedContentBlocker::URISafeToBeLoadedInSecureContext(nsIURI* aURI) {
|
||||
NS_IMETHODIMP
|
||||
nsMixedContentBlocker::ShouldProcess(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aDecision) {
|
||||
if (!aContentLocation) {
|
||||
// aContentLocation may be null when a plugin is loading without an
|
||||
@ -1023,7 +1016,7 @@ nsMixedContentBlocker::ShouldProcess(nsIURI* aContentLocation,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aMimeGuess, aDecision);
|
||||
return ShouldLoad(aContentLocation, aLoadInfo, aDecision);
|
||||
}
|
||||
|
||||
// Record information on when HSTS would have made mixed content not mixed
|
||||
|
@ -83,8 +83,7 @@ class nsMixedContentBlocker : public nsIContentPolicy,
|
||||
*/
|
||||
static nsresult ShouldLoad(bool aHadInsecureImageRedirect,
|
||||
nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess, bool aReportError,
|
||||
int16_t* aDecision);
|
||||
bool aReportError, int16_t* aDecision);
|
||||
static void AccumulateMixedContentHSTS(
|
||||
nsIURI* aURI, bool aActive, const OriginAttributes& aOriginAttributes);
|
||||
|
||||
|
@ -37,7 +37,7 @@ function createChromeScript() {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
if (contentLocation.asciiSpec === EXPECTED_URL) {
|
||||
sendAsyncMessage("loadBlocked", { policyType: loadInfo.externalContentPolicyType});
|
||||
Services.catMan.deleteCategoryEntry(
|
||||
@ -51,7 +51,7 @@ function createChromeScript() {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
};
|
||||
|
@ -68,7 +68,7 @@ bool CSPPermitsResponse(nsILoadInfo* aLoadInfo,
|
||||
}
|
||||
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(uri, aLoadInfo, ""_ns, &decision);
|
||||
rv = NS_CheckContentLoadPolicy(uri, aLoadInfo, &decision);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -318,8 +318,7 @@ already_AddRefed<Promise> ServiceWorkerContainer::Register(
|
||||
|
||||
// Check content policy.
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(scriptURI, secCheckLoadInfo,
|
||||
"application/javascript"_ns, &decision);
|
||||
rv = NS_CheckContentLoadPolicy(scriptURI, secCheckLoadInfo, &decision);
|
||||
if (NS_FAILED(rv)) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
|
@ -380,7 +380,7 @@ class StartResponse final : public Runnable {
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(uri, aLoadInfo, ""_ns, &decision);
|
||||
rv = NS_CheckContentLoadPolicy(uri, aLoadInfo, &decision);
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
return decision == nsIContentPolicy::ACCEPT;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ function setupPolicy() {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad(contentLocation, loadInfo) {
|
||||
// Remember last content type seen for the test url
|
||||
let contentType = loadInfo.externalContentPolicyType;
|
||||
|
||||
@ -62,7 +62,7 @@ function setupPolicy() {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
|
||||
shouldProcess(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
}
|
||||
|
@ -1689,7 +1689,7 @@ nsresult WebSocketImpl::Init(JSContext* aCx, bool aIsSecure,
|
||||
}
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(uri, secCheckLoadInfo, ""_ns, &shouldLoad,
|
||||
rv = NS_CheckContentLoadPolicy(uri, secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -718,8 +718,7 @@ nsresult nsXMLContentSink::MaybeProcessXSLTLink(
|
||||
|
||||
// Do content policy check
|
||||
int16_t decision = nsIContentPolicy::ACCEPT;
|
||||
rv = NS_CheckContentLoadPolicy(url, secCheckLoadInfo,
|
||||
NS_ConvertUTF16toUTF8(aType), &decision,
|
||||
rv = NS_CheckContentLoadPolicy(url, secCheckLoadInfo, &decision,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -15,7 +15,7 @@ NS_IMPL_ISUPPORTS(ImageBlocker, nsIContentPolicy)
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageBlocker::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess, int16_t* aShouldLoad) {
|
||||
int16_t* aShouldLoad) {
|
||||
ExtContentPolicyType contentType = aLoadInfo->GetExternalContentPolicyType();
|
||||
|
||||
*aShouldLoad = nsIContentPolicy::ACCEPT;
|
||||
@ -51,7 +51,6 @@ ImageBlocker::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
|
||||
NS_IMETHODIMP
|
||||
ImageBlocker::ShouldProcess(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aShouldProcess) {
|
||||
// We block images at load level already, so those should not end up here.
|
||||
*aShouldProcess = nsIContentPolicy::ACCEPT;
|
||||
|
@ -730,9 +730,8 @@ static bool ShouldLoadCachedImage(imgRequest* aImgRequest,
|
||||
secCheckLoadInfo->SetSendCSPViolationEvents(aSendCSPViolationReports);
|
||||
|
||||
int16_t decision = nsIContentPolicy::REJECT_REQUEST;
|
||||
rv = NS_CheckContentLoadPolicy(contentLocation, secCheckLoadInfo,
|
||||
""_ns, // mime guess
|
||||
&decision, nsContentUtils::GetContentPolicy());
|
||||
rv = NS_CheckContentLoadPolicy(contentLocation, secCheckLoadInfo, &decision,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
if (NS_FAILED(rv) || !NS_CP_ACCEPTED(decision)) {
|
||||
return false;
|
||||
}
|
||||
@ -760,8 +759,7 @@ static bool ShouldLoadCachedImage(imgRequest* aImgRequest,
|
||||
decision = nsIContentPolicy::REJECT_REQUEST;
|
||||
rv = nsMixedContentBlocker::ShouldLoad(insecureRedirect, contentLocation,
|
||||
secCheckLoadInfo,
|
||||
""_ns, // mime guess
|
||||
true, // aReportError
|
||||
true, // aReportError
|
||||
&decision);
|
||||
if (NS_FAILED(rv) || !NS_CP_ACCEPTED(decision)) {
|
||||
return false;
|
||||
|
@ -363,10 +363,9 @@ bool FontFaceSetDocumentImpl::IsFontLoadAllowed(const gfxFontFaceSrc& aSrc) {
|
||||
nsIContentPolicy::TYPE_FONT);
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(aSrc.mURI->get(), secCheckLoadInfo,
|
||||
""_ns, // mime type
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(aSrc.mURI->get(), secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
|
||||
return NS_SUCCEEDED(rv) && NS_CP_ACCEPTED(shouldLoad);
|
||||
}
|
||||
|
@ -322,10 +322,9 @@ bool FontFaceSetWorkerImpl::IsFontLoadAllowed(const gfxFontFaceSrc& aSrc) {
|
||||
nsIContentPolicy::TYPE_FONT);
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(aSrc.mURI->get(), secCheckLoadInfo,
|
||||
""_ns, // mime type
|
||||
&shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(aSrc.mURI->get(), secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
|
||||
return NS_SUCCEEDED(rv) && NS_CP_ACCEPTED(shouldLoad);
|
||||
}
|
||||
|
@ -881,9 +881,9 @@ nsresult Loader::CheckContentPolicy(nsIPrincipal* aLoadingPrincipal,
|
||||
secCheckLoadInfo->SetCspNonce(aNonce);
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv = NS_CheckContentLoadPolicy(aTargetURI, secCheckLoadInfo,
|
||||
"text/css"_ns, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(aTargetURI, secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
// Asynchronously notify observers (e.g devtools) of CSP failure.
|
||||
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
|
||||
|
@ -36,11 +36,11 @@ var policy = {
|
||||
},
|
||||
|
||||
// nsIContentPolicy implementation
|
||||
shouldLoad: function(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldLoad: function(contentLocation, loadInfo) {
|
||||
info(`shouldLoad is invoked for ${SpecialPowers.wrap(contentLocation).spec}`);
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
},
|
||||
shouldProcess: function(contentLocation, loadInfo, mimeTypeGuess) {
|
||||
shouldProcess: function(contentLocation, loadInfo) {
|
||||
return Ci.nsIContentPolicy.ACCEPT;
|
||||
}
|
||||
}
|
||||
|
@ -369,9 +369,8 @@ void EarlyHintPreloader::MaybeCreateAndInsertPreload(
|
||||
}
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(uri, secCheckLoadInfo, ""_ns, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv = NS_CheckContentLoadPolicy(uri, secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
|
||||
if (NS_FAILED(rv) || NS_CP_REJECTED(shouldLoad)) {
|
||||
return;
|
||||
|
@ -19,7 +19,6 @@ NS_IMPL_ISUPPORTS(nsWebBrowserContentPolicy, nsIContentPolicy)
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aShouldLoad) {
|
||||
MOZ_ASSERT(aShouldLoad, "Null out param");
|
||||
|
||||
@ -60,7 +59,6 @@ nsWebBrowserContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
||||
NS_IMETHODIMP
|
||||
nsWebBrowserContentPolicy::ShouldProcess(nsIURI* aContentLocation,
|
||||
nsILoadInfo* aLoadInfo,
|
||||
const nsACString& aMimeGuess,
|
||||
int16_t* aShouldProcess) {
|
||||
MOZ_ASSERT(aShouldProcess, "Null out param");
|
||||
|
||||
|
@ -159,9 +159,8 @@ nsresult FetchPreloader::CheckContentPolicy(nsIURI* aURI,
|
||||
nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK, mContentPolicyType);
|
||||
|
||||
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
|
||||
nsresult rv =
|
||||
NS_CheckContentLoadPolicy(aURI, secCheckLoadInfo, ""_ns, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
nsresult rv = NS_CheckContentLoadPolicy(aURI, secCheckLoadInfo, &shouldLoad,
|
||||
nsContentUtils::GetContentPolicy());
|
||||
if (NS_SUCCEEDED(rv) && NS_CP_ACCEPTED(shouldLoad)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user