Preserve opaque JSON keys independently of field write guards
Foundry Go checks / check (push) Successful in 2m51s
Foundry Go checks / check (pull_request) Successful in 2m45s

This commit is contained in:
2026-11-07 22:52:31 +08:00
parent 4a89137e38
commit bf8763e0de
2 changed files with 4 additions and 2 deletions
+2 -2
View File
@@ -95,8 +95,8 @@ func modelJSONSafe(value any, depth int) bool {
}
return true
case map[string]any:
for key, item := range value {
if canvasChoice(key, "__proto__", "constructor", "prototype") || !modelJSONSafe(item, depth+1) {
for _, item := range value {
if !modelJSONSafe(item, depth+1) {
return false
}
}
+2
View File
@@ -102,6 +102,8 @@ func TestCanonicalOperationsPreserveOpaquePayloadAndStableMoveIdentity(t *testin
model.Versions[modelChildID] = 1
future := modelTestNode("future", modelRootID)
future["componentId"], future["dataVersion"], future["data"], future["futureEnvelope"] = "plugin.future", float64(42), map[string]any{"nested": map[string]any{"list": []any{"x", float64(2)}}}, map[string]any{"retain": true}
future["data"].(map[string]any)["constructor"] = map[string]any{"retain": true}
future["data"].(map[string]any)["__proto__"] = map[string]any{"ordinary": "JSON data"}
model.Elements["future"] = future
op := modelOperation{ID: modelTestID(1), Changes: []modelChange{{Kind: "field", Target: modelTarget{ID: "a", Incarnation: 1}, Field: "ownerCanvasId", Before: modelJSON(modelRootID), After: modelJSON(modelChildID)}}}
after, touched, err := applyModelOperations(model, []modelOperation{op})