[Pkg-mozext-commits] [greasemonkey] 01/13: Remove apiLeakCheck.

David Prévot taffit at moszumanska.debian.org
Thu Jul 17 20:10:00 UTC 2014


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

taffit pushed a commit to branch master
in repository greasemonkey.

commit 7031a322ee537accabe058136efa3084d448bac5
Author: Anthony Lieuallen <arantius at gmail.com>
Date:   Mon Jun 23 09:28:55 2014 -0400

    Remove apiLeakCheck.
    
    This was always a bit of a hack; expanded principals (used as of GM 2.0) does the same thing, but correctly.
    
    See: http://bugzil.la/1022208
---
 components/greasemonkey.js   | 11 --------
 modules/miscapis.js          | 40 ----------------------------
 modules/util/apiLeakCheck.js | 62 --------------------------------------------
 modules/xmlhttprequester.js  |  4 ---
 4 files changed, 117 deletions(-)

diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index 1662ad9..01956fd 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -182,11 +182,6 @@ function isTempScript(uri) {
 }
 
 function openInTab(safeContentWin, url, aLoadInBackground) {
-  // Skip the first arg, which is hitched rather than passed in.
-  var extern_args = Array.prototype.slice.call(arguments, 1);
-  if (!GM_util.apiLeakCheck("GM_openInTab", extern_args)) {
-    return undefined;
-  }
   if ('undefined' == typeof aLoadInBackground) aLoadInBackground = null;
 
   // Resolve URL relative to the location of the content window.
@@ -219,12 +214,6 @@ function registerMenuCommand(
     wrappedContentWin, script,
     commandName, commandFunc, accessKey, unused, accessKey2
 ) {
-  // Skip the first two args, which are hitched rather than passed in.
-  var extern_args = Array.prototype.slice.call(arguments, 2);
-  if (!GM_util.apiLeakCheck("GM_registerMenuCommand", extern_args)) {
-    return;
-  }
-
   if (wrappedContentWin.top != wrappedContentWin) {
     // Only register menu commands for the top level window.
     return;
diff --git a/modules/miscapis.js b/modules/miscapis.js
index 927f455..924e1be 100644
--- a/modules/miscapis.js
+++ b/modules/miscapis.js
@@ -59,10 +59,6 @@ GM_ScriptStorage.prototype.setValue = function(name, val) {
     throw new Error(this.stringBundle.GetStringFromName('error.args.setValue'));
   }
 
-  if (!GM_util.apiLeakCheck("GM_setValue", arguments)) {
-    return;
-  }
-
   var stmt = this.db.createStatement(
       'INSERT OR REPLACE INTO scriptvals (name, value) VALUES (:name, :value)');
   try {
@@ -78,10 +74,6 @@ GM_ScriptStorage.prototype.setValue = function(name, val) {
 
 
 GM_ScriptStorage.prototype.getValue = function(name, defVal) {
-  if (!GM_util.apiLeakCheck("GM_getValue", arguments)) {
-    return undefined;
-  }
-
   var value = null;
   var stmt = this.db.createStatement(
       'SELECT value FROM scriptvals WHERE name = :name');
@@ -107,10 +99,6 @@ GM_ScriptStorage.prototype.getValue = function(name, defVal) {
 
 
 GM_ScriptStorage.prototype.deleteValue = function(name) {
-  if (!GM_util.apiLeakCheck("GM_deleteValue", arguments)) {
-    return undefined;
-  }
-
   var stmt = this.db.createStatement(
       'DELETE FROM scriptvals WHERE name = :name');
   try {
@@ -125,10 +113,6 @@ GM_ScriptStorage.prototype.deleteValue = function(name) {
 
 
 GM_ScriptStorage.prototype.listValues = function() {
-  if (!GM_util.apiLeakCheck("GM_listValues", arguments)) {
-    return undefined;
-  }
-
   var valueNames = [];
 
   var stmt = this.db.createStatement('SELECT name FROM scriptvals');
@@ -188,36 +172,20 @@ GM_ScriptStoragePrefs.prototype.setValue = function(name, val) {
     throw new Error(this.stringBundle.GetStringFromName('error.args.setValue'));
   }
 
-  if (!GM_util.apiLeakCheck("GM_setValue", arguments)) {
-    return;
-  }
-
   this.prefMan.setValue(name, val);
   this._script.changed('val-set', name);
 };
 
 GM_ScriptStoragePrefs.prototype.getValue = function(name, defVal) {
-  if (!GM_util.apiLeakCheck("GM_getValue", arguments)) {
-    return undefined;
-  }
-
   return this.prefMan.getValue(name, defVal);
 };
 
 GM_ScriptStoragePrefs.prototype.deleteValue = function(name) {
-  if (!GM_util.apiLeakCheck("GM_deleteValue", arguments)) {
-    return undefined;
-  }
-
   return this.prefMan.remove(name);
   this._script.changed('val-del', name);
 };
 
 GM_ScriptStoragePrefs.prototype.listValues = function() {
-  if (!GM_util.apiLeakCheck("GM_listValues", arguments)) {
-    return undefined;
-  }
-
   // See #1637.
   var vals = Array.prototype.slice.call(this.prefMan.listValues());
   vals.__exposedProps__ = {'length': 'r'};
@@ -235,18 +203,10 @@ function GM_Resources(script){
 }
 
 GM_Resources.prototype.getResourceURL = function(aScript, name) {
-  if (!GM_util.apiLeakCheck("GM_getResourceURL", arguments)) {
-    return undefined;
-  }
-
   return ['greasemonkey-script:', aScript.uuid, '/', name].join('');
 };
 
 GM_Resources.prototype.getResourceText = function(name) {
-  if (!GM_util.apiLeakCheck("GM_getResourceText", arguments)) {
-    return undefined;
-  }
-
   return this._getDep(name).textContent;
 };
 
diff --git a/modules/util/apiLeakCheck.js b/modules/util/apiLeakCheck.js
deleted file mode 100644
index 5934551..0000000
--- a/modules/util/apiLeakCheck.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// Examines the stack to determine if an API should be callable.
-
-const EXPORTED_SYMBOLS = ['apiLeakCheck'];
-
-Components.utils.import('resource://greasemonkey/prefmanager.js');
-Components.utils.import('resource://greasemonkey/util.js');
-
-var gAccessViolationString = Components
-    .classes["@mozilla.org/intl/stringbundle;1"]
-    .getService(Components.interfaces.nsIStringBundleService)
-    .createBundle("chrome://greasemonkey/locale/greasemonkey.properties")
-    .GetStringFromName('error.access-violation');
-var gComponentPath = GM_util.getService().filename;
-var gScriptDirPath = (function() {
-  var ios = Components.classes["@mozilla.org/network/io-service;1"]
-      .getService(Components.interfaces.nsIIOService);
-  var scriptDir = GM_util.scriptDir();
-  return ios.newFileURI(scriptDir).spec;
-})();
-
-
-function apiLeakCheck(apiName, origArguments) {
-  var argLen = origArguments.length;
-  for (var i = 0; i < argLen; i++) {
-    var arg = origArguments[i];
-    if (arg && arg.wrappedJSObject) {
-      GM_util.logError(new Error(
-          gAccessViolationString.replace('%1', apiName) + ' (Xray)'
-          ));
-      return false;
-    }
-  }
-
-  var stack = Components.stack;
-  do {
-    // Valid locations for GM API calls are:
-    //  * Greasemonkey scripts.
-    //  * Greasemonkey extension by path.
-    //  * Greasemonkey modules.
-    //  * All of chrome.  (In the script update case, chrome will list values.
-    //        Including Sync modules.)
-    // Anything else on the stack and we will reject the API, to make sure that
-    // the content window (whose path would be e.g. http://...) has no access.
-    if (2 == stack.language
-        && stack.filename !== gComponentPath
-        && stack.filename.substr(0, gScriptDirPath.length) !== gScriptDirPath
-        && stack.filename.substr(0, 24) !== 'resource://greasemonkey/'
-        && stack.filename.substr(0, 25) !== 'resource://services-sync/'
-        && stack.filename.substr(0, 15) !== 'resource://gre/'
-        && stack.filename.substr(0, 9) !== 'chrome://'
-        ) {
-      GM_util.logError(new Error(
-          gAccessViolationString.replace('%1', apiName)
-          ));
-      return false;
-    }
-
-    stack = stack.caller;
-  } while (stack);
-
-  return true;
-}
diff --git a/modules/xmlhttprequester.js b/modules/xmlhttprequester.js
index b052fcb..a56054a 100644
--- a/modules/xmlhttprequester.js
+++ b/modules/xmlhttprequester.js
@@ -17,10 +17,6 @@ function GM_xmlhttpRequester(wrappedContentWin, chromeWindow, originUrl) {
 // can't support mimetype because i think it's only used for forcing
 // text/xml and we can't support that
 GM_xmlhttpRequester.prototype.contentStartRequest = function(details) {
-  if (!GM_util.apiLeakCheck("GM_xmlhttpRequest", arguments)) {
-    return;
-  }
-
   try {
     // Validate and parse the (possibly relative) given URL.
     var uri = GM_util.uriFromUrl(details.url, this.originUrl);

-- 
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