diff options
author | 无闻 <u@gogs.io> | 2015-09-10 05:51:17 -0400 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2015-09-10 05:51:17 -0400 |
commit | c3061c61a74dd6eab802fd37c085b06c761f94e7 (patch) | |
tree | 26bafe2950b0c20edf1b0c7a86870fef4c39d5e6 /modules/base | |
parent | 9899ea71e86215d563581613bdab922cb4cf0d97 (diff) | |
parent | e4d4662074472106f6a2baeb202f242196565482 (diff) | |
download | gitea-c3061c61a74dd6eab802fd37c085b06c761f94e7.tar.gz gitea-c3061c61a74dd6eab802fd37c085b06c761f94e7.zip |
Merge pull request #1609 from denghongcai/develop
Add allow attribute `class` to `<code>` tag
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go index 0e118552aa..fa5202366a 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -15,6 +15,7 @@ import ( "hash" "html/template" "math" + "regexp" "strings" "time" @@ -26,7 +27,8 @@ import ( "github.com/gogits/gogs/modules/setting" ) -var Sanitizer = bluemonday.UGCPolicy() +var Sanitizer = bluemonday.UGCPolicy().AllowAttrs("class").Matching(regexp.MustCompile(`[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&]*`)).OnElements("code") + // Encode string to md5 hex value. func EncodeMd5(str string) string { |