Bug 1319070 - Match against the principal a=al
☠☠ backed out by bf6b75460a25 ☠ ☠
authorTomislav Jovanovic <tomica@gmail.com>
Sun, 04 Dec 2016 05:24:42 +0100
changeset 353225 2f4f0b81600902b19a9c466f3ef6cb3e0ce3209d
parent 353224 4ed8e6215ade1186f734327dd484ac73103d5279
child 353226 b662b0fdd2365ff926db5db7b59d8bb56d1ff36f
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersal
bugs1319070
milestone52.0a2
Bug 1319070 - Match against the principal a=al MozReview-Commit-ID: Cot21QwoZh3
toolkit/components/extensions/ExtensionContent.jsm
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -138,27 +138,36 @@ Script.prototype = {
       urls.push(url);
     }
 
     return urls;
   },
 
   matches(window) {
     let uri = window.document.documentURIObject;
+    let principal = window.document.nodePrincipal;
 
     // If mozAddonManager is present on this page, don't allow
     // content scripts.
     if (window.navigator.mozAddonManager !== undefined) {
       return false;
     }
 
     if (this.match_about_blank && ["about:blank", "about:srcdoc"].includes(uri.spec)) {
       // When matching about:blank/srcdoc documents, the checks below
       // need to be performed against the "owner" document's URI.
-      uri = window.document.nodePrincipal.URI;
+      uri = principal.URI;
+    }
+
+    // Documents from data: URIs also inherit the principal.
+    if (Services.netUtils.URIChainHasFlags(uri, Ci.nsIProtocolHandler.URI_INHERITS_SECURITY_CONTEXT)) {
+      if (!this.match_about_blank) {
+        return false;
+      }
+      uri = principal.URI;
     }
 
     if (!(this.matches_.matches(uri) || this.matches_host_.matchesIgnoringPath(uri))) {
       return false;
     }
 
     if (this.exclude_matches_.matches(uri)) {
       return false;