fix snippet sandboxed execution and snippet regex #41

Merged
merged 1 commit into from Jan 7, 2012
View
8 lib/wheat/data.js
@@ -2,7 +2,7 @@ var Git = require('git-fs'),
Path = require('path'),
Step = require('step'),
util = require(process.binding('natives').util ? 'util' : 'sys'),
- Script = process.binding('evals').Script,
+ Script = require('vm'),
QueryString = require('querystring');
function preProcessMarkdown(markdown) {
@@ -23,10 +23,10 @@ function preProcessMarkdown(markdown) {
// Look for snippet placeholders
var unique = props.uniqueSnippets = {};
- props.snippets = (markdown.match(/\n<[^<>:\s]+\.[a-z]{2,4}(\*|[#].+)?>\n/g) || []).map(
+ props.snippets = (markdown.match(/(\r\n|\n)<[^<>:\s]+\.[a-z]{2,4}(\*|[#].+)?>(\r\n|\n)/g) || []).map(
function (original) {
- var path = original.substr(2, original.length - 4);
-
+ var path = original.slice(original.indexOf("<")+1, original.indexOf(">"));
+
var filename = path;
execute = path[path.length - 1] === "*";
if (execute) {