Reduce eval scope in test env
This commit is contained in:
Vendored
+6
-1
@@ -1,3 +1,4 @@
|
||||
/*global handlebarsEnv */
|
||||
require('./common');
|
||||
|
||||
var _ = require('underscore'),
|
||||
@@ -10,9 +11,13 @@ vm.runInThisContext(fs.readFileSync(__dirname + '/../../dist/handlebars.js'), 'd
|
||||
global.CompilerContext = {
|
||||
compile: function(template, options) {
|
||||
var templateSpec = handlebarsEnv.precompile(template, options);
|
||||
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
|
||||
return handlebarsEnv.template(safeEval(templateSpec));
|
||||
},
|
||||
compileWithPartial: function(template, options) {
|
||||
return handlebarsEnv.compile(template, options);
|
||||
}
|
||||
};
|
||||
|
||||
function safeEval(templateSpec) {
|
||||
return eval('(' + templateSpec + ')');
|
||||
}
|
||||
|
||||
Vendored
+6
-1
@@ -1,3 +1,4 @@
|
||||
/*global handlebarsEnv */
|
||||
require('./common');
|
||||
|
||||
global.Handlebars = require('../../lib');
|
||||
@@ -5,9 +6,13 @@ global.Handlebars = require('../../lib');
|
||||
global.CompilerContext = {
|
||||
compile: function(template, options) {
|
||||
var templateSpec = handlebarsEnv.precompile(template, options);
|
||||
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
|
||||
return handlebarsEnv.template(safeEval(templateSpec));
|
||||
},
|
||||
compileWithPartial: function(template, options) {
|
||||
return handlebarsEnv.compile(template, options);
|
||||
}
|
||||
};
|
||||
|
||||
function safeEval(templateSpec) {
|
||||
return eval('(' + templateSpec + ')');
|
||||
}
|
||||
|
||||
Vendored
+6
-1
@@ -1,3 +1,4 @@
|
||||
/*global handlebarsEnv */
|
||||
require('./common');
|
||||
|
||||
var _ = require('underscore'),
|
||||
@@ -12,7 +13,7 @@ var compiler = require('../../dist/cjs/handlebars/compiler/compiler');
|
||||
global.CompilerContext = {
|
||||
compile: function(template, options) {
|
||||
var templateSpec = compiler.precompile(template, options);
|
||||
return handlebarsEnv.template(eval('(' + templateSpec + ')'));
|
||||
return handlebarsEnv.template(safeEval(templateSpec));
|
||||
},
|
||||
compileWithPartial: function(template, options) {
|
||||
// Hack the compiler on to the environment for these specific tests
|
||||
@@ -22,3 +23,7 @@ global.CompilerContext = {
|
||||
return handlebarsEnv.compile(template, options);
|
||||
}
|
||||
};
|
||||
|
||||
function safeEval(templateSpec) {
|
||||
return eval('(' + templateSpec + ')');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user