mde / ejs

Embedded JavaScript templates -- http://ejs.co
Apache License 2.0
7.74k stars 843 forks source link

bug found #725

Closed pangqianjin closed 1 year ago

pangqianjin commented 1 year ago

https://github.com/mde/ejs/blob/f47d7aedd51a983e4f73045f962b1209096b5800/lib/ejs.js#L422

I noticed this line, it tries to copy the properties from data to opts, but the function: utils.shallowCopyFromList only returns a new Object, giving value operation is for the local variable in function itself.

Should also give the returned value to the opts variable in this line will do it work.

RahulYavvari commented 1 year ago

In JavaScript, objects are typically passed by reference by default when you pass them as arguments to a function. This means that if you modify the object within the function, the changes will persist outside the function as well.