Commit bf0a6f4
fix(core): replace new Function() with CSP-safe SafeExpressionParser
Replaces eval()-equivalent `new Function()` in ExpressionCache.compileExpression()
with a recursive-descent SafeExpressionParser that works under strict CSP
headers that forbid 'unsafe-eval'.
Supports: comparisons, logical/ternary/nullish ops, arithmetic, unary,
dot/bracket/optional-chaining access, formula functions, Math.*, single-param
arrow functions (.filter/.map/.find), array literals, new Date()/RegExp(), all
literal types.
41 new CSP-safety tests added. All 822 tests pass."
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/16c7c01e-a482-4f8c-b565-2e084a49162e
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>1 parent 4027153 commit bf0a6f4
5 files changed
Lines changed: 1055 additions & 10 deletions
File tree
- packages/core/src/evaluator
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
115 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
116 | 126 | | |
117 | 127 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
125 | 136 | | |
126 | 137 | | |
127 | 138 | | |
| |||
0 commit comments