Add extra sanitization rules for RTE contents
This commit is contained in:
@@ -17,6 +17,16 @@ func RichText(in string) string {
|
||||
p.AllowStyles("color").Matching(regexp.MustCompile("(?i)^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$")).Globally()
|
||||
p.AllowStyles("background-color").Matching(regexp.MustCompile("(?i)^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$")).Globally()
|
||||
|
||||
// allow text alignment
|
||||
p.AllowStyles("text-align").Matching(regexp.MustCompile("^(left|center|right|justify)$")).OnElements("span", "p")
|
||||
|
||||
// allow checklists
|
||||
p.AllowAttrs("data-type").Matching(regexp.MustCompile("^(todo_list|todo_item)$")).OnElements("ul", "li")
|
||||
p.AllowAttrs("data-done").Matching(regexp.MustCompile("^(true|false)$")).OnElements("ul", "li")
|
||||
p.AllowAttrs("data-drag-handle").OnElements("li")
|
||||
p.AllowAttrs("contenteditable").OnElements("span", "div")
|
||||
p.AllowAttrs("class").Matching(regexp.MustCompile("^(todo-checkbox|todo-content)$"))
|
||||
|
||||
// some link specifics we need; allow target but assure safety
|
||||
p.AllowAttrs("target").OnElements("a")
|
||||
p.AddTargetBlankToFullyQualifiedLinks(false)
|
||||
|
||||
Reference in New Issue
Block a user