code.gitea.io/gitea@v1.22.3/modules/markup/sanitizer_custom.go (about) 1 // Copyright 2024 The Gitea Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package markup 5 6 import ( 7 "code.gitea.io/gitea/modules/setting" 8 9 "github.com/microcosm-cc/bluemonday" 10 ) 11 12 func (st *Sanitizer) addSanitizerRules(policy *bluemonday.Policy, rules []setting.MarkupSanitizerRule) { 13 for _, rule := range rules { 14 if rule.AllowDataURIImages { 15 policy.AllowDataURIImages() 16 } 17 if rule.Element != "" { 18 if rule.Regexp != nil { 19 policy.AllowAttrs(rule.AllowAttr).Matching(rule.Regexp).OnElements(rule.Element) 20 } else { 21 policy.AllowAttrs(rule.AllowAttr).OnElements(rule.Element) 22 } 23 } 24 } 25 }