From 3a1b859b7418483a628be55b1eadfafd66997d8c Mon Sep 17 00:00:00 2001 From: derin Date: Thu, 15 Sep 2022 14:33:40 +0200 Subject: [PATCH] global policies --- manipulate/sanitize.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/manipulate/sanitize.go b/manipulate/sanitize.go index bb8d2c5..ffe99ce 100644 --- a/manipulate/sanitize.go +++ b/manipulate/sanitize.go @@ -24,8 +24,10 @@ const ( ) var ( - spaceRegex = regexp.MustCompile(`\s+`) - nidRegex = regexp.MustCompile(`^[A-Z]{3}\d{7}$`) + ugcPolicy = bluemonday.UGCPolicy() + strictPolicy = bluemonday.StrictPolicy() + spaceRegex = regexp.MustCompile(`\s+`) + nidRegex = regexp.MustCompile(`^[A-Z]{3}\d{7}$`) ) var ErrNIDInvalid = errors.New("nid_invalid") @@ -35,9 +37,9 @@ func NewSanitizer(kind Kind) *Sanitizer { switch kind { case UGC: - policy = bluemonday.UGCPolicy() + policy = ugcPolicy default: - policy = bluemonday.StrictPolicy() + policy = strictPolicy } return &Sanitizer{policy: policy}