summaryrefslogtreecommitdiffstats
path: root/modules/markup/html.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-02-19 21:36:43 +0000
committerGitHub <noreply@github.com>2021-02-19 22:36:43 +0100
commitaa4f9180e4932a9813e898bf3bd9ac91924eeb03 (patch)
treee181203ffc52a8bb1740fdb81aeeeba5183c42bf /modules/markup/html.go
parent39aa11f9c0d8aabd188f543d60752e0b8ff95cc5 (diff)
downloadgitea-aa4f9180e4932a9813e898bf3bd9ac91924eeb03.tar.gz
gitea-aa4f9180e4932a9813e898bf3bd9ac91924eeb03.zip
Clarify the suffices and prefixes of setting.AppSubURL and setting.AppURL (#12999)
Also removes some unnecessary uses of fmt.Sprintf and adds documentation strings Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/markup/html.go')
-rw-r--r--modules/markup/html.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index 2c2feb0b34..b254fd083f 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -89,11 +89,7 @@ func isLinkStr(link string) bool {
func getIssueFullPattern() *regexp.Regexp {
if issueFullPattern == nil {
- appURL := setting.AppURL
- if len(appURL) > 0 && appURL[len(appURL)-1] != '/' {
- appURL += "/"
- }
- issueFullPattern = regexp.MustCompile(appURL +
+ issueFullPattern = regexp.MustCompile(regexp.QuoteMeta(setting.AppURL) +
`\w+/\w+/(?:issues|pulls)/((?:\w{1,10}-)?[1-9][0-9]*)([\?|#]\S+.(\S+)?)?\b`)
}
return issueFullPattern
@@ -636,6 +632,9 @@ func mentionProcessor(ctx *postProcessCtx, node *html.Node) {
mention := node.Data[loc.Start:loc.End]
var teams string
teams, ok := ctx.metas["teams"]
+ // FIXME: util.URLJoin may not be necessary here:
+ // - setting.AppURL is defined to have a terminal '/' so unless mention[1:]
+ // is an AppSubURL link we can probably fallback to concatenation.
// team mention should follow @orgName/teamName style
if ok && strings.Contains(mention, "/") {
mentionOrgAndTeam := strings.Split(mention, "/")