diff --git a/plugins/events.go b/plugins/events.go index e997891..cb6d80d 100644 --- a/plugins/events.go +++ b/plugins/events.go @@ -23,6 +23,20 @@ func PreventTooManyIndexableTags(max int) func(context.Context, *nostr.Event) (b } } +// PreventLargeTags rejects events that have indexable tag values greater than maxTagValueLen. +func PreventLargeTags(maxTagValueLen int) func(context.Context, *nostr.Event) (bool, string) { + return func(ctx context.Context, event *nostr.Event) (reject bool, msg string) { + for _, tag := range event.Tags { + if len(tag) > 1 && len(tag[0]) == 1 { + if len(tag[1]) > maxTagValueLen { + return true, "event contains too large tags" + } + } + } + return false, "" + } +} + // RestrictToSpecifiedKinds returns a function that can be used as a RejectFilter that will reject // any events with kinds different than the specified ones. func RestrictToSpecifiedKinds(kinds ...uint16) func(context.Context, *nostr.Event) (bool, string) {