Changeset 628
- Timestamp:
- 01/19/08 15:44:21 (11 months ago)
- Files:
-
- trunk/src/chrome/chromeFiles/content/miscapis.js (modified) (5 diffs)
- trunk/src/chrome/chromeFiles/content/xmlhttprequester.js (modified) (1 diff)
- trunk/src/components/greasemonkey.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/chrome/chromeFiles/content/miscapis.js
r612 r628 8 8 9 9 GM_ScriptStorage.prototype.setValue = function(name, val) { 10 GM_apiLeakCheck(); 10 if (!GM_apiLeakCheck("GM_setValue")) { 11 return; 12 } 11 13 12 14 this.prefMan.setValue(name, val); … … 14 16 15 17 GM_ScriptStorage.prototype.getValue = function(name, defVal) { 16 GM_apiLeakCheck(); 18 if (!GM_apiLeakCheck("GM_getValue")) { 19 return; 20 } 17 21 18 22 return this.prefMan.getValue(name, defVal); … … 24 28 25 29 GM_Resources.prototype.getResourceURL = function(name) { 26 GM_apiLeakCheck(); 30 if (!GM_apiLeakCheck("GM_getResourceURL")) { 31 return; 32 } 27 33 28 34 var dep = this.getDep_(name); … … 46 52 47 53 GM_Resources.prototype.getResourceText = function(name) { 48 GM_apiLeakCheck(); 54 if (!GM_apiLeakCheck("GM_getResourceText")) { 55 return; 56 } 49 57 50 58 var dep = this.getDep_(name); … … 73 81 74 82 GM_ScriptLogger.prototype.log = function(message) { 75 GM_apiLeakCheck(); 83 if (!GM_apiLeakCheck("GM_log")) { 84 return; 85 } 76 86 77 87 GM_log(this.prefix + message, true); trunk/src/chrome/chromeFiles/content/xmlhttprequester.js
r605 r628 13 13 // text/xml and we can't support that 14 14 GM_xmlhttpRequester.prototype.contentStartRequest = function(details) { 15 GM_apiLeakCheck(); 15 if (!GM_apiLeakCheck("GM_xmlhttpRequest")) { 16 return; 17 } 16 18 17 19 // don't actually need the timer functionality, but this pops it trunk/src/components/greasemonkey.js
r627 r628 8 8 const appSvc = Cc["@mozilla.org/appshell/appShellService;1"] 9 9 .getService(Ci.nsIAppShellService); 10 11 const gmSvcFilename = Components.stack.filename; 10 12 11 13 function alert(msg) { … … 16 18 17 19 // Examines the stack to determine if an API should be callable. 18 // NOTE: This function's mechanism relies on the fact that it is implemented 19 // in this file. 20 function GM_apiLeakCheck() { 20 function GM_apiLeakCheck(apiName) { 21 21 var stack = Components.stack; 22 var gmSvcFilename = stack.filename;23 22 24 23 do { … … 28 27 if ('chrome' != stack.filename.substr(0, 6) && 29 28 gmSvcFilename != stack.filename) { 30 throw new Error("Greasemonkey access violation"); 29 GM_logError(new Error("Greasemonkey access violation: unsafeWindow " + 30 "cannot call " + apiName + ".")); 31 return false; 31 32 } 32 33 } … … 34 35 stack = stack.caller; 35 36 } while (stack); 37 38 return true; 36 39 }; 37 40 … … 335 338 registerMenuCommand: function(unsafeContentWin, commandName, commandFunc, 336 339 accelKey, accelModifiers, accessKey) { 337 GM_apiLeakCheck(); 340 if (!GM_apiLeakCheck("GM_registerMenuCommand")) { 341 return; 342 } 338 343 339 344 var command = {name: commandName, … … 350 355 351 356 openInTab: function(unsafeContentWin, url) { 352 GM_apiLeakCheck(); 357 if (!GM_apiLeakCheck("GM_openInTab")) { 358 return; 359 } 353 360 354 361 var unsafeTop = new XPCNativeWrapper(unsafeContentWin, "top").top;
