Skip to content

Commit f4d3bf7

Browse files
authored
issue-keyword class is being incorrectly stripped off spans (#16163)
Bluemonday sanitizer regexp rules are not additive, so the addition of the icons, emojis and chroma syntax policy has led to this being stripped. Signed-off-by: Andrew Thornton <art27@cantab.net>
1 parent 3bf7a83 commit f4d3bf7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

modules/markup/sanitizer.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ func ReplaceSanitizer() {
5050
sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)
5151
}
5252

53-
// Allow keyword markup
54-
sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`^` + keywordClass + `$`)).OnElements("span")
55-
5653
// Allow classes for anchors
5754
sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`ref-issue`)).OnElements("a")
5855

@@ -68,8 +65,8 @@ func ReplaceSanitizer() {
6865
// Allow classes for emojis
6966
sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`emoji`)).OnElements("img")
7067

71-
// Allow icons, emojis, and chroma syntax on span
72-
sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`^((icon(\s+[\p{L}\p{N}_-]+)+)|(emoji))$|^([a-z][a-z0-9]{0,2})$`)).OnElements("span")
68+
// Allow icons, emojis, chroma syntax and keyword markup on span
69+
sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`^((icon(\s+[\p{L}\p{N}_-]+)+)|(emoji))$|^([a-z][a-z0-9]{0,2})$|^` + keywordClass + `$`)).OnElements("span")
7370

7471
// Allow data tables
7572
sanitizer.policy.AllowAttrs("class").Matching(regexp.MustCompile(`data-table`)).OnElements("table")

0 commit comments

Comments
 (0)