summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-03-12 02:23:34 +0000
committertechknowlogick <matti@mdranta.net>2019-03-11 22:23:34 -0400
commitb2e9894988a8cb486f8838f4bf532401124802c4 (patch)
tree7fc62cb89d394f0edb026726c9a732b35ab47f19 /models
parent663874e8bee253dcaa95b03adb519c5685774351 (diff)
downloadgitea-b2e9894988a8cb486f8838f4bf532401124802c4.tar.gz
gitea-b2e9894988a8cb486f8838f4bf532401124802c4.zip
Fix reported issue in repo description (#6306)
Diffstat (limited to 'models')
-rw-r--r--models/repo.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go
index 4d7320a789..2822f7d718 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -722,10 +722,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.