[tbb-commits] [tor-browser/tor-browser-52.1.0esr-7.0-2] fixup! Bug 12827: Create preference to disable SVG.

gk at torproject.org gk at torproject.org
Wed Apr 26 07:13:17 UTC 2017


commit 2d386f0b0ce34aaf97b814da1867bb94a93b62a2
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Wed Apr 19 16:29:59 2017 -0400

    fixup! Bug 12827: Create preference to disable SVG.
    
    If the top window's URI is not available, check for the system principal
    to determine if SVGs may be used.  This fixes bug 21962.
---
 layout/svg/nsSVGUtils.cpp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/nsSVGUtils.cpp
index 1217e92..98dd287e 100644
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -114,6 +114,7 @@ NS_SVGEnabledForChannel(nsIChannel *aChannel)
 
 #ifdef DEBUG_SVG_ENABLE
   nsAutoCString topDocSpec;  // Set if approved via a whitelisted top doc.
+  bool checkedSystemPrincipal = false;
 #endif
 
   bool isSVGAllowed = false;
@@ -152,6 +153,18 @@ NS_SVGEnabledForChannel(nsIChannel *aChannel)
               if (isSVGAllowed)
                 topDocURI->GetSpec(topDocSpec);
 #endif
+            } else {
+              // Unable to retrieve the top window's URI. Fallback to checking
+              // the system principal (see bug 21962).
+#ifdef DEBUG_SVG_ENABLE
+              checkedSystemPrincipal = true;
+#endif
+              nsCOMPtr<nsIScriptObjectPrincipal> scriptObjPrin =
+                                                    do_QueryInterface(topWin);
+              if (scriptObjPrin) {
+                isSVGAllowed = nsContentUtils::IsSystemPrincipal(
+                                               scriptObjPrin->GetPrincipal());
+              }
             }
           }
         }
@@ -166,7 +179,10 @@ NS_SVGEnabledForChannel(nsIChannel *aChannel)
   if (uri)
     uri->GetSpec(spec);
 
-  if (topDocSpec.IsEmpty()) {
+  if (checkedSystemPrincipal) {
+    printf("NS_SVGEnabledForChannel for %s: %s (via system principal check)\n",
+           spec.get(), isSVGAllowed ? "YES" : "NO");
+  } else if (topDocSpec.IsEmpty()) {
     printf("NS_SVGEnabledForChannel for %s: %s\n", spec.get(),
            isSVGAllowed ? "YES" : "NO");
   } else {



More information about the tbb-commits mailing list