Skip to content

Commit a2d365c

Browse files
authored
fix #1501 ssh hangs caused by #1461 (#1513)
1 parent f995bcc commit a2d365c

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

modules/markdown/sanitizer.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"regexp"
1010
"sync"
1111

12-
"code.gitea.io/gitea/modules/log"
1312
"code.gitea.io/gitea/modules/setting"
1413

1514
"github.com/microcosm-cc/bluemonday"
@@ -28,7 +27,6 @@ var sanitizer = &Sanitizer{}
2827
// Multiple calls to this function will only create one instance of Sanitizer during
2928
// entire application lifecycle.
3029
func NewSanitizer() {
31-
log.Trace("Markdown: sanitizer initialization requested")
3230
sanitizer.init.Do(func() {
3331
sanitizer.policy = bluemonday.UGCPolicy()
3432
// We only want to allow HighlightJS specific classes for code blocks
@@ -40,16 +38,12 @@ func NewSanitizer() {
4038

4139
// Custom URL-Schemes
4240
sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)
43-
44-
log.Trace("Markdown: sanitizer initialized")
4541
})
4642
}
4743

4844
// Sanitize takes a string that contains a HTML fragment or document and applies policy whitelist.
4945
func Sanitize(s string) string {
50-
if sanitizer.policy == nil {
51-
NewSanitizer()
52-
}
46+
NewSanitizer()
5347
return sanitizer.policy.Sanitize(s)
5448
}
5549

@@ -59,8 +53,6 @@ func SanitizeBytes(b []byte) []byte {
5953
// nothing to sanitize
6054
return b
6155
}
62-
if sanitizer.policy == nil {
63-
NewSanitizer()
64-
}
56+
NewSanitizer()
6557
return sanitizer.policy.SanitizeBytes(b)
6658
}

0 commit comments

Comments
 (0)