ejs icon indicating copy to clipboard operation
ejs copied to clipboard

Stuck in infinite loop when template is unescaped

Open niklabh opened this issue 11 years ago • 0 comments

This code will run in an infinite loop eventually taking all memory and killing the node process (Allocation failed - process out of memory):

var ejs = require('ejs');
var ejsOpts = {
  open: '{{',
  close: '}}'
};
var template = " {{=nik }";
console.log("start");
var compiled = ejs.compile(template, ejsOpts);
console.log("compiled", compiled);

The problem is at file lib/ejs.js line 144,173 (prase function) end becomes -1 and i(loop counter) always getting set to 1, and the for loop never ends.

niklabh avatar Feb 05 '14 11:02 niklabh