@almadar/evaluator 2.12.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1210,6 +1210,7 @@ function evalArrayDropLast(args, evaluate2, ctx) {
|
|
|
1210
1210
|
}
|
|
1211
1211
|
|
|
1212
1212
|
// std/object.ts
|
|
1213
|
+
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
1213
1214
|
function evalLambda(lambdaExpr, evaluate2, ctx, ...values) {
|
|
1214
1215
|
if (!isSExpr(lambdaExpr) || getOperator(lambdaExpr) !== "fn") {
|
|
1215
1216
|
return evaluate2(lambdaExpr, ctx);
|
|
@@ -1272,6 +1273,9 @@ function evalObjectSet(args, evaluate2, ctx) {
|
|
|
1272
1273
|
if (!path) return obj ?? {};
|
|
1273
1274
|
const result = structuredClone(obj ?? {});
|
|
1274
1275
|
const parts = path.split(".");
|
|
1276
|
+
if (parts.some((p) => FORBIDDEN_KEYS.has(p))) {
|
|
1277
|
+
return result;
|
|
1278
|
+
}
|
|
1275
1279
|
let current = result;
|
|
1276
1280
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
1277
1281
|
const part = parts[i];
|
|
@@ -1309,6 +1313,7 @@ function evalObjectDeepMerge(args, evaluate2, ctx) {
|
|
|
1309
1313
|
function deepMerge(target, source) {
|
|
1310
1314
|
const result = { ...target };
|
|
1311
1315
|
for (const key of Object.keys(source)) {
|
|
1316
|
+
if (FORBIDDEN_KEYS.has(key)) continue;
|
|
1312
1317
|
if (source[key] !== null && typeof source[key] === "object" && !Array.isArray(source[key]) && target[key] !== null && typeof target[key] === "object" && !Array.isArray(target[key])) {
|
|
1313
1318
|
result[key] = deepMerge(
|
|
1314
1319
|
target[key],
|