by gus_massa · 4y ago · 0 comments
What are the security implications of this? Does the code run in the server or my computer? Does it only recognize math functions, or it can also run "alert"?
Eg.
const a = 3;
const b = 2;
const expression = new Expression(`${a}*${b}(6/3(5--2))`);
const result = expression.evaluate();
document.getElementById("app").innerHTML = `a*b( 6 / 3( 5 - - 2 ) )= ${result}`;
Edit: formating const a = 2;
const b = 6;
const c = 3
const expression = new Expression('a \ b * c')
const result = expression.scope({a, b, c}).evaluate();
document.getElementById("app").innerHTML `${a} \ ${b} *
${c}= ${result}`I was trying to change the expression, but I need to change it twice. At the top where `expression` is defined and at the bottom to show it in the html. Is it possible to "see" what is inside an Expression object?