diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-01-29 19:36:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-29 19:36:57 +0800 |
commit | b28fb9085185025415847d7075f1cdf83abb3b56 (patch) | |
tree | 0e0cc62b67546ebcd35c297cd35f097fe486b445 /internal/markup/sanitizer.go | |
parent | 8b7fa6627fb0f75adb8d1ca4ad953cf3b9b7dc87 (diff) |
all: use lazyregexp (#5911)
* Use lazyregexp
* all: fix imports and usages
Diffstat (limited to 'internal/markup/sanitizer.go')
-rw-r--r-- | internal/markup/sanitizer.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/internal/markup/sanitizer.go b/internal/markup/sanitizer.go index e8d76b23..981e1c73 100644 --- a/internal/markup/sanitizer.go +++ b/internal/markup/sanitizer.go @@ -5,11 +5,11 @@ package markup import ( - "regexp" "sync" "github.com/microcosm-cc/bluemonday" + "gogs.io/gogs/internal/lazyregexp" "gogs.io/gogs/internal/setting" ) @@ -30,10 +30,10 @@ var sanitizer = &Sanitizer{ func NewSanitizer() { sanitizer.init.Do(func() { // We only want to allow HighlightJS specific classes for code blocks - sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`^language-\w+$`)).OnElements("code") + sanitizer.policy.AllowAttrs("class").Matching(lazyregexp.New(`^language-\w+$`).Regexp()).OnElements("code") // Checkboxes - sanitizer.policy.AllowAttrs("type").Matching(regexp.MustCompile(`^checkbox$`)).OnElements("input") + sanitizer.policy.AllowAttrs("type").Matching(lazyregexp.New(`^checkbox$`).Regexp()).OnElements("input") sanitizer.policy.AllowAttrs("checked", "disabled").OnElements("input") // Data URLs |