1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-12 12:38:20 +00:00

backport 6306 (#6308)

This commit is contained in:
techknowlogick
2019-03-12 06:58:49 -04:00
committed by Lunny Xiao
parent 59a64c0e1d
commit c7bbfd8f5e
2 changed files with 53 additions and 3 deletions

View File

@@ -719,10 +719,12 @@ var (
// DescriptionHTML does special handles to description and return HTML string.
func (repo *Repository) DescriptionHTML() template.HTML {
sanitize := func(s string) string {
return fmt.Sprintf(`<a href="%[1]s" target="_blank" rel="noopener noreferrer">%[1]s</a>`, s)
desc, err := markup.RenderDescriptionHTML([]byte(repo.Description), repo.HTMLURL(), repo.ComposeMetas())
if err != nil {
log.Error(4, "Failed to render description for %s (ID: %d): %v", repo.Name, repo.ID, err)
return template.HTML(markup.Sanitize(repo.Description))
}
return template.HTML(descPattern.ReplaceAllStringFunc(markup.Sanitize(repo.Description), sanitize))
return template.HTML(markup.Sanitize(string(desc)))
}
// LocalCopyPath returns the local repository copy path.