[Pkg-mozext-commits] [greasemonkey] 27/41: Address errors when navigating to `.user.js` URLs serving HTML.

David Prévot taffit at moszumanska.debian.org
Thu Apr 30 22:06:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit e95d81477c82c839e77fa09ae29184294b559cb8
Author: Anthony Lieuallen <arantius at gmail.com>
Date:   Wed Apr 22 15:31:26 2015 -0400

    Address errors when navigating to `.user.js` URLs serving HTML.
    
    Fixes #1998
---
 content/framescript.js             | 13 ++++++++++---
 modules/installPolicy.js           | 18 +++++++++++-------
 modules/util/findMessageManager.js | 10 +++++++---
 3 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/content/framescript.js b/content/framescript.js
index a52413f..0fb8213 100644
--- a/content/framescript.js
+++ b/content/framescript.js
@@ -135,10 +135,17 @@ ContentObserver.prototype.createScriptFromObject = function(aObject) {
 
 
 ContentObserver.prototype.loadFailedScript = function(aMessage) {
+  var url = aMessage.data.url;
+  var loadFlags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
+  var referer = aMessage.data.referer
+      && GM_util.uriFromUrl(aMessage.data.referer);
+  var postData = null;
+  var headers = null;
+
+  var webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
+
   ignoreNextScript();
-  docShell.loadURI(
-      GM_util.uriFromUrl(aMessage.data.url),
-      /* loadInfo */ null, /* aLoadFlags */ null, /* firstParty */ true);
+  webNav.loadURI(url, loadFlags, referer, postData, headers);
 };
 
 
diff --git a/modules/installPolicy.js b/modules/installPolicy.js
index 7698785..74e4e8d 100644
--- a/modules/installPolicy.js
+++ b/modules/installPolicy.js
@@ -92,7 +92,6 @@ var InstallPolicy = {
       return ret;
     }
 
-
     var tmpResult = Services.cpmm.sendSyncMessage(
         'greasemonkey:url-is-temp-file', {'url': aContentURI.spec});
     if (tmpResult.length && tmpResult[0]) {
@@ -100,15 +99,20 @@ var InstallPolicy = {
     }
 
     if (!gIgnoreNextScript) {
-      ret = Ci.nsIContentPolicy.REJECT_REQUEST;
       var windowMm = GM_util.findMessageManager(aContext);
-      windowMm.sendAsyncMessage('greasemonkey:script-install', {
-        'referer': aOriginURI.spec,
-        'url': aContentURI.spec,
-      });
+      if (!windowMm) {
+        dump('ERROR ignoring script ' + aContentURI.spec + ' because no content'
+            + ' message manager could be located from ' + aContext + '\n');
+      } else {
+        ret = Ci.nsIContentPolicy.REJECT_REQUEST;
+        windowMm.sendAsyncMessage('greasemonkey:script-install', {
+          'referer': aOriginURI.spec,
+          'url': aContentURI.spec,
+        });
+      }
     }
-    gIgnoreNextScript = false;
 
+    gIgnoreNextScript = false;
     return ret;
   },
 
diff --git a/modules/util/findMessageManager.js b/modules/util/findMessageManager.js
index 78cadd9..3b6d17e 100644
--- a/modules/util/findMessageManager.js
+++ b/modules/util/findMessageManager.js
@@ -18,7 +18,11 @@ function findMessageManager(aContext) {
         .QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem;
   }
 
-  return docShell
-      .QueryInterface(Ci.nsIInterfaceRequestor)
-      .getInterface(Ci.nsIContentFrameMessageManager);
+  try {
+    return docShell
+        .QueryInterface(Ci.nsIInterfaceRequestor)
+        .getInterface(Ci.nsIContentFrameMessageManager);
+  } catch (e) {
+    return null;
+  }
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list