[tor-commits] [tor-browser/tor-browser-68.1.0esr-9.0-2] Bug 467035 - Add new internal DTD content types r=ckerschb

gk at torproject.org gk at torproject.org
Mon Sep 16 13:41:46 UTC 2019


commit 93c30885b92760fcdf6bd06b235ddd3c87b09b97
Author: Alex Catarineu <acat at torproject.org>
Date:   Wed Jul 3 17:28:25 2019 +0000

    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 9af71cb85b3f..50767baa3637 100644
--- a/dom/base/nsContentPolicyUtils.h
+++ b/dom/base/nsContentPolicyUtils.h
@@ -137,6 +137,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 "<Unknown Type>";
   }
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index 9c409099c9af..b80c6c91093b 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -3467,6 +3467,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 540c12424925..670acb28b555 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 dc6b0f9b2025..cf30ba9e36f3 100644
--- a/dom/security/nsCSPUtils.cpp
+++ b/dom/security/nsCSPUtils.cpp
@@ -235,6 +235,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)





More information about the tor-commits mailing list