mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Bugfix and removed dead code
This commit is contained in:
parent
5a8b6afc03
commit
36ba38d685
@ -19,44 +19,6 @@ Sandbox.prototype.parse = function(code) {
|
||||
return this.parser.parse(code);
|
||||
};
|
||||
|
||||
Sandbox.prototype.execute = function(code,globals) {
|
||||
var globalNames = [],
|
||||
globalValues = [],
|
||||
collectGlobals = function(globals) {
|
||||
if(globals) {
|
||||
for(var g in globals) {
|
||||
globalNames.push(g);
|
||||
globalValues.push(globals[g]);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Collect the supplied globals
|
||||
collectGlobals(globals);
|
||||
// Add the default globals
|
||||
collectGlobals({
|
||||
tiddlywiki: "5"
|
||||
});
|
||||
// Compose the code
|
||||
var out = [];
|
||||
out.push("(function(");
|
||||
out.push(globalNames.join(","));
|
||||
out.push(") { return ");
|
||||
out.push(code);
|
||||
out.push(";})");
|
||||
// Parse the code
|
||||
var compiledCode = out.join(""),
|
||||
tree = this.parser.parse(out.join(""));
|
||||
// XXX: Sanitise the code by checking for references to globals, stripping out eval()
|
||||
// Execute it
|
||||
var result;
|
||||
try {
|
||||
result = eval(compiledCode).apply(null,globalValues);
|
||||
} catch(err) {
|
||||
result = "{{** Evaluation error: " + err + " **}}";
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
exports.Sandbox = Sandbox;
|
||||
|
||||
})();
|
@ -60,6 +60,7 @@ WikiTextCompiler.prototype.compileAsHtml = function(treenode) {
|
||||
}
|
||||
pushString("<" + tagBits.join(" ") + (options.selfClosing ? " /" : ""));
|
||||
if(options.insertAfterAttributes) {
|
||||
pushString(" ");
|
||||
output.push(options.insertAfterAttributes);
|
||||
}
|
||||
pushString(">");
|
||||
|
Loading…
Reference in New Issue
Block a user