Skip to content

Commit

Permalink
global policies
Browse files Browse the repository at this point in the history
  • Loading branch information
derinil committed Sep 15, 2022
1 parent 114a465 commit 3a1b859
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions manipulate/sanitize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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}
Expand Down

0 comments on commit 3a1b859

Please sign in to comment.