diff --git a/models/repo.go b/models/repo.go index 0eb795773..3a6610582 100644 --- a/models/repo.go +++ b/models/repo.go @@ -7,13 +7,11 @@ package models import ( "bytes" "fmt" - "html/template" "io/ioutil" "os" "os/exec" "path" "path/filepath" - "regexp" "sort" "strings" "time" @@ -493,18 +491,6 @@ func (repo *Repository) NextIssueIndex() int64 { return int64(repo.NumIssues+repo.NumPulls) + 1 } -var ( - DescPattern = regexp.MustCompile(`https?://\S+`) -) - -// DescriptionHtml does special handles to description and return HTML string. -func (repo *Repository) DescriptionHtml() template.HTML { - sanitize := func(s string) string { - return fmt.Sprintf(`%[1]s`, s) - } - return template.HTML(DescPattern.ReplaceAllStringFunc(markdown.Sanitizer.Sanitize(repo.Description), sanitize)) -} - func (repo *Repository) LocalCopyPath() string { return path.Join(setting.AppDataPath, "tmp/local-repo", com.ToStr(repo.ID)) } diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index a4beb2014..642c44e4a 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -16,7 +16,7 @@ {{.NumForks}} - {{if .DescriptionHtml}}
{{.DescriptionHtml}}
{{end}} + {{if .Description}}{{.Description | Str2html}}
{{end}}{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}
{{end}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 44b7d186d..f313e7fd1 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -5,7 +5,7 @@ {{template "base/alert" .}} {{if .PageIsRepoHome}}- {{if .Repository.DescriptionHtml}}{{.Repository.DescriptionHtml}}{{else}}{{.i18n.Tr "repo.no_desc"}}{{end}} + {{if .Repository.Description}}{{.Repository.Description | Str2html}}{{else}}{{.i18n.Tr "repo.no_desc"}}{{end}} {{.Repository.Website}}