Skip to content

Commit

Permalink
Added a temporary hack to get pegs working serverside
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Ruston committed Dec 28, 2011
1 parent ed2e2ab commit 04dc396
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 2 additions & 3 deletions js/Sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ Sandbox.prototype.execute = function(code,globals) {
out.push(code);
out.push(";})");
// Parse the code
var code = out.join(""),
var compiledCode = out.join(""),
tree = this.parser.parse(out.join(""));
// XXX: Sanitise the code by checking for references to globals, stripping out eval()
console.log(tree);
// Execute it
var result;
try {
result = eval(code).apply(null,globalValues);
result = eval(compiledCode).apply(null,globalValues);
} catch(err) {
result = "{{** Evaluation error: " + err + " **}}";
}
Expand Down
4 changes: 4 additions & 0 deletions tiddlywiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
tiddlerInput.register(store);
tiddlerOutput.register(store);

// Frightful temporary hack, but setup the sandbox for evaluated macro parameters
var Sandbox = require("./js/Sandbox.js").Sandbox;
store.sandbox = new Sandbox(fs.readFileSync("parsers/javascript.pegjs","utf8"));

// Add the shadow tiddlers that are built into TiddlyWiki
var shadowShadowStore = new WikiStore({
shadowStore: null
Expand Down
4 changes: 4 additions & 0 deletions wikitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ store.registerTextProcessor("text/x-tiddlywiki",new WikiTextProcessor({
}));
tiddlerInput.register(store);

// Frightful temporary hack, but setup the sandbox for evaluated macro parameters
var Sandbox = require("./js/Sandbox.js").Sandbox;
store.sandbox = new Sandbox(fs.readFileSync("parsers/javascript.pegjs","utf8"));

for(f=0; f<files.length; f++) {
extname = path.extname(files[f]);
if(extname === ".tid") {
Expand Down

0 comments on commit 04dc396

Please sign in to comment.