From b28fb9085185025415847d7075f1cdf83abb3b56 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Wed, 29 Jan 2020 19:36:57 +0800 Subject: all: use lazyregexp (#5911) * Use lazyregexp * all: fix imports and usages --- internal/markup/sanitizer.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/markup/sanitizer.go') 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 -- cgit v1.2.3