updated regex sanitization

-allows %
-updated escape characters to \
This commit is contained in:
mbrannen 2022-03-07 23:15:55 -07:00
parent cc6a4d0ce2
commit 31ea56084e

@ -17,7 +17,7 @@ export function expr(
const expr = args.join(""); const expr = args.join("");
// Sanitize the math expression // Sanitize the math expression
const sanitizedExpr = expr.replace(/s+/g, "").replace(/[^-()\d/*+.]/g, ""); const sanitizedExpr = expr.replace(/s+/g, "").replace(/[^-()\d\*+.\%]/g, "");
let result; let result;
try { try {
result = eval(sanitizedExpr); result = eval(sanitizedExpr);