Preserve opaque JSON keys independently of field write guards
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user