diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 5ac3c5581..43abaaccf 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -28,7 +28,9 @@ type Cache struct { } // NewCache - -func NewCache(rpc noderpc.INode, accounts account.Repository, contracts contract.Repository, protocols protocol.Repository, sanitizer *bluemonday.Policy) *Cache { +func NewCache(rpc noderpc.INode, accounts account.Repository, contracts contract.Repository, protocols protocol.Repository) *Cache { + sanitizer := bluemonday.UGCPolicy() + sanitizer.AllowAttrs("em") return &Cache{ ccache.New(ccache.Configure().MaxSize(1000)), rpc, diff --git a/internal/config/context.go b/internal/config/context.go index b41e2ad39..855600c40 100644 --- a/internal/config/context.go +++ b/internal/config/context.go @@ -20,7 +20,6 @@ import ( "github.com/baking-bad/bcdhub/internal/postgres" "github.com/baking-bad/bcdhub/internal/postgres/core" "github.com/baking-bad/bcdhub/internal/services/mempool" - "github.com/microcosm-cc/bluemonday" "github.com/pkg/errors" ) @@ -51,24 +50,21 @@ type Context struct { SmartRollups smartrollup.Repository Partitions *postgres.PartitionManager - Cache *cache.Cache - Sanitizer *bluemonday.Policy + Cache *cache.Cache } // NewContext - func NewContext(network types.Network, opts ...ContextOption) *Context { ctx := &Context{ - Sanitizer: bluemonday.UGCPolicy(), - Network: network, + Network: network, } - ctx.Sanitizer.AllowAttrs("em") for _, opt := range opts { opt(ctx) } ctx.Cache = cache.NewCache( - ctx.RPC, ctx.Accounts, ctx.Contracts, ctx.Protocols, ctx.Sanitizer, + ctx.RPC, ctx.Accounts, ctx.Contracts, ctx.Protocols, ) return ctx } diff --git a/internal/parsers/operations/operation_group_test.go b/internal/parsers/operations/operation_group_test.go index f6cf5b186..050e58062 100644 --- a/internal/parsers/operations/operation_group_test.go +++ b/internal/parsers/operations/operation_group_test.go @@ -31,7 +31,6 @@ import ( "github.com/baking-bad/bcdhub/internal/parsers" "github.com/go-pg/pg/v10" "github.com/golang/mock/gomock" - "github.com/microcosm-cc/bluemonday" ) func TestGroup_Parse(t *testing.T) { @@ -387,7 +386,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -423,7 +422,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -599,7 +598,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -785,7 +784,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -880,7 +879,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -982,7 +981,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -1168,7 +1167,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -1266,7 +1265,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -1401,7 +1400,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{ @@ -1470,7 +1469,7 @@ func TestGroup_Parse(t *testing.T) { Operations: operaitonsRepo, Scripts: scriptRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, storage: map[string]int64{ @@ -2073,7 +2072,7 @@ func TestGroup_Parse(t *testing.T) { Scripts: scriptRepo, GlobalConstants: globalConstantRepo, Cache: cache.NewCache( - rpc, accountsRepo, contractRepo, protoRepo, bluemonday.UGCPolicy(), + rpc, accountsRepo, contractRepo, protoRepo, ), }, paramsOpts: []ParseParamsOption{