1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-28 02:50:27 +00:00

Bugfix and removed dead code

This commit is contained in:
Jeremy Ruston 2012-01-03 12:42:34 +00:00
parent 5a8b6afc03
commit 36ba38d685
2 changed files with 1 additions and 38 deletions

View File

@ -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;
})();

View File

@ -60,6 +60,7 @@ WikiTextCompiler.prototype.compileAsHtml = function(treenode) {
}
pushString("<" + tagBits.join(" ") + (options.selfClosing ? " /" : ""));
if(options.insertAfterAttributes) {
pushString(" ");
output.push(options.insertAfterAttributes);
}
pushString(">");