From dbce01f2ff30c026d0ee4369a39c5a58411f83ce Mon Sep 17 00:00:00 2001 From: Alex Catarineu Date: Wed, 3 Jul 2019 17:28:25 +0000 Subject: [PATCH] Bug 467035 - Add new internal DTD content types r=ckerschb Differential Revision: https://phabricator.services.mozilla.com/D35232 --HG-- extra : moz-landing-system : lando --- dom/base/nsContentPolicyUtils.h | 2 ++ dom/base/nsContentUtils.h | 4 ++++ dom/base/nsIContentPolicy.idl | 12 ++++++++++++ dom/cache/DBSchema.cpp | 4 +++- dom/fetch/InternalRequest.cpp | 2 ++ dom/security/nsCSPUtils.cpp | 2 ++ extensions/permissions/nsContentBlocker.cpp | 2 ++ 7 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dom/base/nsContentPolicyUtils.h b/dom/base/nsContentPolicyUtils.h index 28746a92796c..ddf5ebb32fce 100644 --- a/dom/base/nsContentPolicyUtils.h +++ b/dom/base/nsContentPolicyUtils.h @@ -138,6 +138,8 @@ inline const char* NS_CP_ContentTypeName(uint32_t contentType) { CASE_RETURN(TYPE_SPECULATIVE); CASE_RETURN(TYPE_INTERNAL_MODULE); CASE_RETURN(TYPE_INTERNAL_MODULE_PRELOAD); + CASE_RETURN(TYPE_INTERNAL_DTD); + CASE_RETURN(TYPE_INTERNAL_FORCE_ALLOWED_DTD); default: return ""; } diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 24580f129536..a8b1e51652d5 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -3326,6 +3326,10 @@ nsContentUtils::InternalContentPolicyTypeToExternal(nsContentPolicyType aType) { case nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD: return nsIContentPolicy::TYPE_STYLESHEET; + case nsIContentPolicy::TYPE_INTERNAL_DTD: + case nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD: + return nsIContentPolicy::TYPE_DTD; + default: return aType; } diff --git a/dom/base/nsIContentPolicy.idl b/dom/base/nsIContentPolicy.idl index 5acbf9b8d9d2..13137cee7bc6 100644 --- a/dom/base/nsIContentPolicy.idl +++ b/dom/base/nsIContentPolicy.idl @@ -364,6 +364,18 @@ interface nsIContentPolicy : nsISupports */ const nsContentPolicyType TYPE_INTERNAL_MODULE_PRELOAD = 46; + /** + * Indicates a DTD loaded by an XML document the URI of which could + * not be mapped to a known local DTD. + */ + const nsContentPolicyType TYPE_INTERNAL_DTD = 47; + + /** + * Indicates a TYPE_INTERNAL_DTD which will not be blocked no matter + * what principal is being loaded from. + */ + const nsContentPolicyType TYPE_INTERNAL_FORCE_ALLOWED_DTD = 48; + /* When adding new content types, please update nsContentBlocker, * NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective, * DoContentSecurityChecks, all nsIContentPolicy implementations, the diff --git a/dom/cache/DBSchema.cpp b/dom/cache/DBSchema.cpp index 7aee38a8c49c..4db507b2cb55 100644 --- a/dom/cache/DBSchema.cpp +++ b/dom/cache/DBSchema.cpp @@ -333,7 +333,9 @@ static_assert(nsIContentPolicy::TYPE_INVALID == 0 && nsIContentPolicy::TYPE_SAVEAS_DOWNLOAD == 43 && nsIContentPolicy::TYPE_SPECULATIVE == 44 && nsIContentPolicy::TYPE_INTERNAL_MODULE == 45 && - nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD == 46, + nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD == 46 && + nsIContentPolicy::TYPE_INTERNAL_DTD == 47 && + nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD == 48, "nsContentPolicyType values are as expected"); namespace { diff --git a/dom/fetch/InternalRequest.cpp b/dom/fetch/InternalRequest.cpp index dada8d6df418..6456fe55c9aa 100644 --- a/dom/fetch/InternalRequest.cpp +++ b/dom/fetch/InternalRequest.cpp @@ -254,6 +254,8 @@ RequestDestination InternalRequest::MapContentPolicyTypeToRequestDestination( destination = RequestDestination::_empty; break; case nsIContentPolicy::TYPE_DTD: + case nsIContentPolicy::TYPE_INTERNAL_DTD: + case nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD: destination = RequestDestination::_empty; break; case nsIContentPolicy::TYPE_FONT: diff --git a/dom/security/nsCSPUtils.cpp b/dom/security/nsCSPUtils.cpp index a761de446ad6..ae3527a0ed6f 100644 --- a/dom/security/nsCSPUtils.cpp +++ b/dom/security/nsCSPUtils.cpp @@ -268,6 +268,8 @@ CSPDirective CSP_ContentTypeToDirective(nsContentPolicyType aType) { case nsIContentPolicy::TYPE_DTD: case nsIContentPolicy::TYPE_OTHER: case nsIContentPolicy::TYPE_SPECULATIVE: + case nsIContentPolicy::TYPE_INTERNAL_DTD: + case nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD: return nsIContentSecurityPolicy::DEFAULT_SRC_DIRECTIVE; // csp shold not block top level loads, e.g. in case diff --git a/extensions/permissions/nsContentBlocker.cpp b/extensions/permissions/nsContentBlocker.cpp index bd98eb5aa5a7..3c4246b2ecc2 100644 --- a/extensions/permissions/nsContentBlocker.cpp +++ b/extensions/permissions/nsContentBlocker.cpp @@ -71,6 +71,8 @@ static const nsLiteralCString kTypeString[] = { NS_LITERAL_CSTRING("speculative"), NS_LITERAL_CSTRING(""), // TYPE_INTERNAL_MODULE NS_LITERAL_CSTRING(""), // TYPE_INTERNAL_MODULE_PRELOAD + NS_LITERAL_CSTRING(""), // TYPE_INTERNAL_DTD + NS_LITERAL_CSTRING(""), // TYPE_INTERNAL_FORCE_ALLOWED_DTD }; #define NUMBER_OF_TYPES MOZ_ARRAY_LENGTH(kTypeString)