Skip to content

Commit 09e7acd

Browse files
committed
Fix build-errors
1 parent fa24b11 commit 09e7acd

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

models/repo.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ func (repo *Repository) DescriptionHTML() template.HTML {
582582
sanitize := func(s string) string {
583583
return fmt.Sprintf(`<a href="%[1]s" target="_blank" rel="noopener">%[1]s</a>`, s)
584584
}
585-
return template.HTML(descPattern.ReplaceAllStringFunc(markdown.Sanitizer.Sanitize(repo.Description), sanitize))
585+
return template.HTML(descPattern.ReplaceAllStringFunc(markdown.Sanitize(repo.Description), sanitize))
586586
}
587587

588588
// LocalCopyPath returns the local repository copy path
@@ -844,8 +844,8 @@ func cleanUpMigrateGitConfig(configPath string) error {
844844
// createDelegateHooks creates all the hooks scripts for the repo
845845
func createDelegateHooks(repoPath string) (err error) {
846846
var (
847-
hookNames = []string{"pre-receive", "update", "post-receive"}
848-
hookTpl = fmt.Sprintf("#!/usr/bin/env %s\ndata=$(cat)\nexitcodes=\"\"\nhookname=$(basename $0)\nGIT_DIR=${GIT_DIR:-$(dirname $0)}\n\nfor hook in ${GIT_DIR}/hooks/${hookname}.d/*; do\ntest -x \"${hook}\" || continue\necho \"${data}\" | \"${hook}\"\nexitcodes=\"${exitcodes} $?\"\ndone\n\nfor i in ${exitcodes}; do\n[ ${i} -eq 0 ] || exit ${i}\ndone\n", setting.ScriptType)
847+
hookNames = []string{"pre-receive", "update", "post-receive"}
848+
hookTpl = fmt.Sprintf("#!/usr/bin/env %s\ndata=$(cat)\nexitcodes=\"\"\nhookname=$(basename $0)\nGIT_DIR=${GIT_DIR:-$(dirname $0)}\n\nfor hook in ${GIT_DIR}/hooks/${hookname}.d/*; do\ntest -x \"${hook}\" || continue\necho \"${data}\" | \"${hook}\"\nexitcodes=\"${exitcodes} $?\"\ndone\n\nfor i in ${exitcodes}; do\n[ ${i} -eq 0 ] || exit ${i}\ndone\n", setting.ScriptType)
849849
giteaHookTpls = []string{
850850
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' pre-receive\n", setting.ScriptType, setting.AppPath, setting.CustomConf),
851851
fmt.Sprintf("#!/usr/bin/env %s\n\"%s\" hook --config='%s' update $1 $2 $3\n", setting.ScriptType, setting.AppPath, setting.CustomConf),

models/user.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (u *User) UpdateDiffViewStyle(style string) error {
163163
func (u *User) AfterSet(colName string, _ xorm.Cell) {
164164
switch colName {
165165
case "full_name":
166-
u.FullName = markdown.Sanitizer.Sanitize(u.FullName)
166+
u.FullName = markdown.Sanitize(u.FullName)
167167
case "created_unix":
168168
u.Created = time.Unix(u.CreatedUnix, 0).Local()
169169
case "updated_unix":
@@ -867,7 +867,7 @@ func updateUser(e Engine, u *User) error {
867867
u.Website = base.TruncateString(u.Website, 255)
868868
u.Description = base.TruncateString(u.Description, 255)
869869

870-
u.FullName = markdown.Sanitizer.Sanitize(u.FullName)
870+
u.FullName = markdown.Sanitize(u.FullName)
871871
_, err := e.Id(u.ID).AllCols().Update(u)
872872
return err
873873
}

modules/markdown/sanitizer.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"regexp"
1010
"sync"
1111

12+
"code.gitea.io/gitea/modules/log"
13+
1214
"github.com/microcosm-cc/bluemonday"
13-
log "gopkg.in/clog.v1"
1415

1516
"github.com/gogits/gogs/modules/setting"
1617
)
@@ -28,7 +29,7 @@ var sanitizer = &Sanitizer{}
2829
// Multiple calls to this function will only create one instance of Sanitizer during
2930
// entire application lifecycle.
3031
func NewSanitizer() {
31-
log.Trace("Markup: sanitizer initialization requested")
32+
log.Trace("Markdown: sanitizer initialization requested")
3233
sanitizer.init.Do(func() {
3334
sanitizer.policy = bluemonday.UGCPolicy()
3435
// We only want to allow HighlightJS specific classes for code blocks
@@ -41,7 +42,7 @@ func NewSanitizer() {
4142
// Custom URL-Schemes
4243
sanitizer.policy.AllowURLSchemes(setting.Markdown.CustomURLSchemes...)
4344

44-
log.Trace("Markup: sanitizer initialized")
45+
log.Trace("Markdown: sanitizer initialized")
4546
})
4647
}
4748

modules/markdown/sanitizer_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import (
99
"testing"
1010

1111
. "github.com/smartystreets/goconvey/convey"
12-
13-
. "github.com/gogits/gogs/modules/markup"
1412
)
1513

1614
func Test_Sanitizer(t *testing.T) {
17-
BuildSanitizer()
15+
NewSanitizer()
1816
Convey("Sanitize HTML string and bytes", t, func() {
1917
testCases := []string{
2018
// Regular

0 commit comments

Comments
 (0)