This commit is contained in:
Alexey Terentyev 2018-07-22 08:30:37 +00:00 committed by GitHub
commit e70d411447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -775,7 +775,7 @@ func (repo *Repository) NextIssueIndex() int64 {
}
var (
descPattern = regexp.MustCompile(`https?://\S+`)
descPattern = regexp.MustCompile(`https?://[a-zA-Z0-9-_@:;%.,+~#?&/=|!$]+`)
)
// DescriptionHTML does special handles to description and return HTML string.

View File

@ -5,6 +5,7 @@
package models
import (
"fmt"
"path"
"testing"
@ -176,3 +177,14 @@ func TestTransferOwnership(t *testing.T) {
CheckConsistencyFor(t, &Repository{}, &User{}, &Team{})
}
func TestRepoDescriptionHTML(t *testing.T) {
url := "https://github.com/go-gitea/gitea"
description := "GitHub repo: (%s)"
repo := &Repository{Description: fmt.Sprintf(description, url)}
actual := repo.DescriptionHTML()
expected := fmt.Sprintf(description,
fmt.Sprintf(`<a href="%[1]s" target="_blank" rel="noopener">%[1]s</a>`, url))
assert.EqualValues(t, expected, actual)
}