Ticket #137: gm_unsafe_hack.fixed.diff
| File gm_unsafe_hack.fixed.diff, 5.6 kB (added by jtra..@dragoncat.net, 5 months ago) |
|---|
-
components/greasemonkey.js
old new 258 258 259 259 console = firebugConsole ? firebugConsole : new GM_console(script); 260 260 261 storage = new GM_ScriptStorage(script );261 storage = new GM_ScriptStorage(script, script.unsafe); 262 262 xmlhttpRequester = new GM_xmlhttpRequester(unsafeContentWin, 263 appSvc.hiddenDOMWindow); 264 resources = new GM_Resources(script); 263 appSvc.hiddenDOMWindow, 264 script.unsafe); 265 resources = new GM_Resources(script, script.unsafe); 265 266 266 267 sandbox.window = safeWin; 267 268 sandbox.document = sandbox.window.document; -
chrome/chromeFiles/content/config.js
old new 87 87 scriptResource._charset = childNode.getAttribute("charset"); 88 88 script._resources.push(scriptResource); 89 89 break; 90 case "Unsafe": 91 script.unsafe = parseInt(childNode.firstChild.nodeValue); 92 break; 90 93 } 91 94 } 92 95 … … 109 112 for (var i = 0, scriptObj; scriptObj = this._scripts[i]; i++) { 110 113 var scriptNode = doc.createElement("Script"); 111 114 115 var unsafeNode = doc.createElement("Unsafe"); 116 unsafeNode.appendChild(doc.createTextNode(scriptObj.unsafe)); 117 scriptNode.appendChild(unsafeNode); 118 112 119 for (var j = 0; j < scriptObj._includes.length; j++) { 113 120 var includeNode = doc.createElement("Include"); 114 121 includeNode.appendChild(doc.createTextNode(scriptObj._includes[j])); … … 215 222 case "exclude": 216 223 script._excludes.push(match[2]); 217 224 break; 225 case "unsafe": 226 // Allow a script to mark itself as 'unsafe'. This mark causes 227 // the apiLeakCheck functionality to be avoided thus preventing 228 // some scripts from breaking under the combination of FF3.0 229 // and GM 0.8. This should very likely be avoided and there 230 // there should be some extra warning on install and in the 231 // script list if there is a script marked unsafe installed. 232 // Unfortunately, for any script which relies on pulling code 233 // from a trusted source and evaluating it via eval, this is 234 // the only way I could come up with which would allow that code 235 // to correctly call GM_* functions which otherwise got blocked. 236 script.unsafe = parseInt(match[2]); 237 break; 218 238 case "require": 219 239 var reqUri = ioservice.newURI(match[2], null, uri); 220 240 var scriptRequire = new ScriptRequire(script); … … 415 435 this._excludes = []; 416 436 this._requires = []; 417 437 this._resources = []; 438 this.unsafe = 0; 418 439 } 419 440 420 441 Script.prototype = { -
chrome/chromeFiles/content/miscapis.js
old new 1 function GM_ScriptStorage(script ) {1 function GM_ScriptStorage(script, unsafe) { 2 2 this.prefMan = new GM_PrefManager(["scriptvals.", 3 3 script.namespace, 4 4 "/", 5 5 script.name, 6 6 "."].join("")); 7 this.unsafe = unsafe; 7 8 } 8 9 9 10 GM_ScriptStorage.prototype.setValue = function(name, val) { 10 if (! GM_apiLeakCheck("GM_setValue")) {11 if (!this.unsafe && !GM_apiLeakCheck("GM_setValue")) { 11 12 return; 12 13 } 13 14 … … 15 16 }; 16 17 17 18 GM_ScriptStorage.prototype.getValue = function(name, defVal) { 18 if (! GM_apiLeakCheck("GM_getValue")) {19 if (!this.unsafe && !GM_apiLeakCheck("GM_getValue")) { 19 20 return; 20 21 } 21 22 22 23 return this.prefMan.getValue(name, defVal); 23 24 }; 24 25 25 function GM_Resources(script ){26 function GM_Resources(script, unsafe){ 26 27 this.script = script; 28 this.unsafe = unsafe; 27 29 } 28 30 29 31 GM_Resources.prototype.getResourceURL = function(name) { 30 if (! GM_apiLeakCheck("GM_getResourceURL")) {32 if (!this.unsafe && !GM_apiLeakCheck("GM_getResourceURL")) { 31 33 return; 32 34 } 33 35 … … 35 37 }; 36 38 37 39 GM_Resources.prototype.getResourceText = function(name) { 38 if (! GM_apiLeakCheck("GM_getResourceText")) {40 if (!this.unsafe && !GM_apiLeakCheck("GM_getResourceText")) { 39 41 return; 40 42 } 41 43 -
chrome/chromeFiles/content/xmlhttprequester.js
old new 1 function GM_xmlhttpRequester(unsafeContentWin, chromeWindow ) {1 function GM_xmlhttpRequester(unsafeContentWin, chromeWindow, unsafe) { 2 2 this.unsafeContentWin = unsafeContentWin; 3 3 this.chromeWindow = chromeWindow; 4 this.unsafe = unsafe; 4 5 } 5 6 6 7 // this function gets called by user scripts in content security scope to … … 12 13 // can't support mimetype because i think it's only used for forcing 13 14 // text/xml and we can't support that 14 15 GM_xmlhttpRequester.prototype.contentStartRequest = function(details) { 15 if (! GM_apiLeakCheck("GM_xmlhttpRequest")) {16 if (!this.unsafe && !GM_apiLeakCheck("GM_xmlhttpRequest")) { 16 17 return; 17 18 } 18 19
