-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split sanitizer functions and fine-tune some tests (#31192)
- Loading branch information
1 parent
352a2ca
commit a427595
Showing
8 changed files
with
270 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package markup | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"github.com/microcosm-cc/bluemonday" | ||
) | ||
|
||
func (st *Sanitizer) addSanitizerRules(policy *bluemonday.Policy, rules []setting.MarkupSanitizerRule) { | ||
for _, rule := range rules { | ||
if rule.AllowDataURIImages { | ||
policy.AllowDataURIImages() | ||
} | ||
if rule.Element != "" { | ||
if rule.Regexp != nil { | ||
policy.AllowAttrs(rule.AllowAttr).Matching(rule.Regexp).OnElements(rule.Element) | ||
} else { | ||
policy.AllowAttrs(rule.AllowAttr).OnElements(rule.Element) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.