Skip to content

Commit 09e277d

Browse files
committed
Add some more regex validations to attributes of elements inside filepreview
1 parent 21ca3ad commit 09e277d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/markup/sanitizer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ func createDefaultPolicy() *bluemonday.Policy {
126126
policy.AllowAttrs("class").Matching(regexp.MustCompile("^file-preview-box$")).OnElements("div")
127127
policy.AllowAttrs("class").Matching(regexp.MustCompile("^ui table$")).OnElements("div")
128128
policy.AllowAttrs("class").Matching(regexp.MustCompile("^header$")).OnElements("div")
129-
policy.AllowAttrs("data-line-number").OnElements("span")
129+
policy.AllowAttrs("data-line-number").Matching(regexp.MustCompile("^[0-9]+$")).OnElements("span")
130130
policy.AllowAttrs("class").Matching(regexp.MustCompile("^text small grey$")).OnElements("span")
131-
policy.AllowAttrs("rel").OnElements("td")
131+
policy.AllowAttrs("rel").Matching(regexp.MustCompile("^L[0-9]+$")).OnElements("td")
132132
policy.AllowAttrs("class").Matching(regexp.MustCompile("^file-preview*")).OnElements("table")
133133
policy.AllowAttrs("class").Matching(regexp.MustCompile("^lines-escape$")).OnElements("td")
134134
policy.AllowAttrs("class").Matching(regexp.MustCompile("^toggle-escape-button btn interact-bg$")).OnElements("a")

0 commit comments

Comments
 (0)