Changeset 605

Show
Ignore:
Timestamp:
01/18/08 22:09:00 (11 months ago)
Author:
boo..@youngpup.net
Message:

Add anthony's patch for GM api leaks.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/chrome/chromeFiles/content/menucommander.js

    r548 r605  
    2020GM_MenuCommander.prototype.registerMenuCommand = 
    2121  function(commandName, commandFunc, accelKey, accelModifiers, accessKey) { 
     22    GM_apiLeakCheck(); 
     23 
    2224    GM_log("> GM_MenuCommander.registerMenuCommand"); 
    2325 
  • trunk/src/chrome/chromeFiles/content/miscapis.js

    r548 r605  
    88 
    99GM_ScriptStorage.prototype.setValue = function(name, val) { 
     10  GM_apiLeakCheck(); 
     11 
     12  if (GM_apiLeakCheck()) { 
     13    alert('ALERT ALERT detected leaked GM_ API, aborting!\n'); 
     14    return; 
     15  } 
     16 
    1017  this.prefMan.setValue(name, val); 
    1118}; 
    1219 
    1320GM_ScriptStorage.prototype.getValue = function(name, defVal) { 
     21  GM_apiLeakCheck(); 
     22 
    1423  return this.prefMan.getValue(name, defVal); 
    1524}; 
     
    2029 
    2130GM_Resources.prototype.getResourceURL = function(name) { 
     31  GM_apiLeakCheck(); 
     32 
    2233  var dep = this.getDep_(name); 
    2334 
     
    4051 
    4152GM_Resources.prototype.getResourceText = function(name) { 
     53  GM_apiLeakCheck(); 
     54 
    4255  var dep = this.getDep_(name); 
    4356  return getContents(getDependencyFileURI(this.script, dep)); 
     
    6578 
    6679GM_ScriptLogger.prototype.log = function(message) { 
     80  GM_apiLeakCheck(); 
     81 
    6782  GM_log(this.prefix + message, true); 
    6883}; 
  • trunk/src/chrome/chromeFiles/content/utils.js

    r548 r605  
    66var GM_consoleService = Components.classes["@mozilla.org/consoleservice;1"] 
    77                        .getService(Components.interfaces.nsIConsoleService); 
     8 
     9function GM_apiLeakCheck() { 
     10  var stack = Components.stack; 
     11 
     12  do { 
     13    if (2 == stack.language) { 
     14      if ('file' != stack.filename.substr(0, 4) && 
     15          'chrome' != stack.filename.substr(0, 6)) { 
     16        throw new Error("Greasemonkey access violation"); 
     17      } 
     18    } 
     19 
     20    stack = stack.caller; 
     21  } while (stack); 
     22}; 
    823 
    924function GM_isDef(thing) { 
  • trunk/src/chrome/chromeFiles/content/xmlhttprequester.js

    r590 r605  
    1313// text/xml and we can't support that 
    1414GM_xmlhttpRequester.prototype.contentStartRequest = function(details) { 
     15  GM_apiLeakCheck(); 
     16 
    1517  // don't actually need the timer functionality, but this pops it 
    1618  // out into chromeWindow's thread so that we get that security 
  • trunk/src/components/greasemonkey.js

    r548 r605  
    313313 
    314314  openInTab: function(unsafeContentWin, url) { 
     315    GM_apiLeakCheck(); 
     316 
    315317    var unsafeTop = new XPCNativeWrapper(unsafeContentWin, "top").top; 
    316318