Skip to content

Commit acc24c2

Browse files
committed
fix
1 parent 81adb01 commit acc24c2

File tree

12 files changed

+70
-172
lines changed

12 files changed

+70
-172
lines changed

modules/markup/sanitizer_default.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package markup
55

66
import (
7+
"html/template"
78
"io"
89
"net/url"
910
"regexp"
@@ -92,9 +93,9 @@ func (st *Sanitizer) createDefaultPolicy() *bluemonday.Policy {
9293
return policy
9394
}
9495

95-
// Sanitize takes a string that contains a HTML fragment or document and applies policy whitelist.
96-
func Sanitize(s string) string {
97-
return GetDefaultSanitizer().defaultPolicy.Sanitize(s)
96+
// Sanitize use default sanitizer policy to sanitize a string
97+
func Sanitize(s string) template.HTML {
98+
return template.HTML(GetDefaultSanitizer().defaultPolicy.Sanitize(s))
9899
}
99100

100101
// SanitizeReader sanitizes a Reader

modules/markup/sanitizer_default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ func TestSanitizer(t *testing.T) {
6969
}
7070

7171
for i := 0; i < len(testCases); i += 2 {
72-
assert.Equal(t, testCases[i+1], Sanitize(testCases[i]))
72+
assert.Equal(t, testCases[i+1], string(Sanitize(testCases[i])))
7373
}
7474
}

modules/templates/helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ func safeHTML(s any) template.HTML {
176176
panic(fmt.Sprintf("unexpected type %T", s))
177177
}
178178

179-
// SanitizeHTML sanitizes the input by pre-defined markdown rules
179+
// SanitizeHTML sanitizes the input by default sanitization rules.
180180
func SanitizeHTML(s string) template.HTML {
181-
return template.HTML(markup.Sanitize(s))
181+
return markup.Sanitize(s)
182182
}
183183

184184
func htmlEscape(s any) template.HTML {

0 commit comments

Comments
 (0)