Skip to content

Commit 9cf7dbc

Browse files
committed
issue-keyword class is being incorrectly stripped off spans
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 <[email protected]>
1 parent 3d99131 commit 9cf7dbc

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

modules/markup/sanitizer.go

Lines changed: 2 additions & 5 deletions
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)