<feed xmlns='http://www.w3.org/2005/Atom'>
<title>opencut/apps/web/src/utils/__tests__/math.test.ts, branch main</title>
<subtitle></subtitle>
<id>http://git.cashmere.rs/opencut/atom/apps/web/src/utils/__tests__/math.test.ts?h=main</id>
<link rel='self' href='http://git.cashmere.rs/opencut/atom/apps/web/src/utils/__tests__/math.test.ts?h=main'/>
<link rel='alternate' type='text/html' href='http://git.cashmere.rs/opencut/'/>
<updated>2026-03-29T16:27:05Z</updated>
<entry>
<title>fix(security): replace new Function() with safe math expression parser (#753)</title>
<updated>2026-03-29T16:27:05Z</updated>
<author>
<name>Rayan Salhab</name>
<email>r.salhab@aiyexpertsolutions.com</email>
</author>
<published>2026-03-29T16:27:05Z</published>
<link rel='alternate' type='text/html' href='http://git.cashmere.rs/opencut/commit/?id=eb66e03f0e67c3b04c863c2b5540c65495bf621d'/>
<id>urn:sha1:eb66e03f0e67c3b04c863c2b5540c65495bf621d</id>
<content type='text'>
* fix(security): replace new Function() with safe math expression parser

Replace the dangerous new Function() constructor in evaluateMathExpression()
with a recursive descent parser that safely evaluates basic arithmetic
expressions.

The Function constructor is a security anti-pattern that could enable
arbitrary code execution if the validation regex is ever bypassed or
relaxed. The new parser:

- Only supports numbers, +, -, *, /, parentheses, and whitespace
- Has no eval-like functionality that could execute arbitrary code
- Maintains backward compatibility with existing expressions
- Handles operator precedence and parentheses correctly

Fixes #725

* Apply suggestion from @coderabbitai[bot]

Co-authored-by: coderabbitai[bot] &lt;136622811+coderabbitai[bot]@users.noreply.github.com&gt;

---------

Co-authored-by: Maze &lt;167211895+mazeincoding@users.noreply.github.com&gt;
Co-authored-by: coderabbitai[bot] &lt;136622811+coderabbitai[bot]@users.noreply.github.com&gt;</content>
</entry>
</feed>
