Skip to content

fix #1501 ssh hangs caused by #1461 #1513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions modules/markdown/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"regexp"
"sync"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"

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

// Custom URL-Schemes
sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)

log.Trace("Markdown: sanitizer initialized")
})
}

// Sanitize takes a string that contains a HTML fragment or document and applies policy whitelist.
func Sanitize(s string) string {
if sanitizer.policy == nil {
NewSanitizer()
}
NewSanitizer()
return sanitizer.policy.Sanitize(s)
}

Expand All @@ -59,8 +53,6 @@ func SanitizeBytes(b []byte) []byte {
// nothing to sanitize
return b
}
if sanitizer.policy == nil {
NewSanitizer()
}
NewSanitizer()
return sanitizer.policy.SanitizeBytes(b)
}