mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-06 17:34:12 +01:00
Fix Firefox exploding with OOM errors when stringifying certain functions.
This commit is contained in:
@@ -255,13 +255,32 @@ var Template = Module("Template", {
|
|||||||
})(), template[help ? "HelpLink" : "helpLink"]);
|
})(), template[help ? "HelpLink" : "helpLink"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Fixes some strange stack rewinds on NS_ERROR_OUT_OF_MEMORY
|
||||||
|
// exceptions that we can't catch.
|
||||||
|
stringify: function (arg) {
|
||||||
|
if (!callable(arg))
|
||||||
|
return String(arg);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this._sandbox.arg = arg;
|
||||||
|
return Cu.evalInSandbox("String(arg)", this._sandbox);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
this._sandbox.arg = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_sandbox: Class.Memoize(function () Cu.Sandbox(this, { wantXrays: false })),
|
||||||
|
|
||||||
// if "processStrings" is true, any passed strings will be surrounded by " and
|
// if "processStrings" is true, any passed strings will be surrounded by " and
|
||||||
// any line breaks are displayed as \n
|
// any line breaks are displayed as \n
|
||||||
highlight: function highlight(arg, processStrings, clip) {
|
highlight: function highlight(arg, processStrings, clip) {
|
||||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||||
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
|
// some objects like window.JSON or getBrowsers()._browsers need the try/catch
|
||||||
try {
|
try {
|
||||||
let str = clip ? util.clip(String(arg), clip) : String(arg);
|
let str = this.stringify(arg);
|
||||||
|
if (clip)
|
||||||
|
str = util.clip(str, clip);
|
||||||
switch (arg == null ? "undefined" : typeof arg) {
|
switch (arg == null ? "undefined" : typeof arg) {
|
||||||
case "number":
|
case "number":
|
||||||
return <span highlight="Number">{str}</span>;
|
return <span highlight="Number">{str}</span>;
|
||||||
|
|||||||
@@ -898,7 +898,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
keys.push([i, <>{key}{noVal ? "" : <>: {value}</>}
</>]);
|
keys.push([i, <>{key}{noVal ? "" : <>: {value}</>}
</>]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {
|
||||||
|
util.reportError(e);
|
||||||
|
}
|
||||||
|
|
||||||
function compare(a, b) {
|
function compare(a, b) {
|
||||||
if (!isNaN(a[0]) && !isNaN(b[0]))
|
if (!isNaN(a[0]) && !isNaN(b[0]))
|
||||||
|
|||||||
Reference in New Issue
Block a user