Skip to content

Commit

Permalink
Added JSON encoder to disable escaping html symbols
Browse files Browse the repository at this point in the history
Signed-off-by: Oleh Moskovych <[email protected]>
  • Loading branch information
Moskovych committed Sep 18, 2023
1 parent 6cd7ca1 commit e8d1289
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion stores/json/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,24 @@ func (store Store) treeBranchFromJSONDecoder(dec *json.Decoder) (sops.TreeBranch
}
}

// Encoder to disable escaping html symbols
// See: https://github.com/getsops/sops/issues/881
func jsonMarshal(v interface{}) ([]byte, error) {
buffer := &bytes.Buffer{}
encoder := json.NewEncoder(buffer)
encoder.SetEscapeHTML(false)
err := encoder.Encode(v)
return buffer.Bytes(), err
}

func (store Store) encodeValue(v interface{}) ([]byte, error) {
switch v := v.(type) {
case sops.TreeBranch:
return store.encodeTree(v)
case []interface{}:
return store.encodeArray(v)
default:
return json.Marshal(v)
return jsonMarshal(v)
}
}

Expand Down

0 comments on commit e8d1289

Please sign in to comment.