Skip to content

Commit 80098bd

Browse files
lafrikszeripath
authored andcommitted
Fix go-get URL generation (#5905)
1 parent 57a69ef commit 80098bd

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

models/repo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"html/template"
1313
"io/ioutil"
14+
"net/url"
1415
"os"
1516
"os/exec"
1617
"path"
@@ -834,7 +835,7 @@ type CloneLink struct {
834835

835836
// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
836837
func ComposeHTTPSCloneURL(owner, repo string) string {
837-
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
838+
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, url.QueryEscape(owner), url.QueryEscape(repo))
838839
}
839840

840841
func (repo *Repository) cloneLink(e Engine, isUncyclo bool) *CloneLink {

modules/context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func Contexter() macaron.Handler {
209209
if err == nil && len(repo.DefaultBranch) > 0 {
210210
branchName = repo.DefaultBranch
211211
}
212-
prefix := setting.AppURL + path.Join(ownerName, repoName, "src", "branch", branchName)
212+
prefix := setting.AppURL + path.Join(url.QueryEscape(ownerName), url.QueryEscape(repoName), "src", "branch", branchName)
213213
c.Header().Set("Content-Type", "text/html")
214214
c.WriteHeader(http.StatusOK)
215215
c.Write([]byte(com.Expand(`<!doctype html>

modules/context/repo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package context
88
import (
99
"fmt"
1010
"io/ioutil"
11+
"net/url"
1112
"path"
1213
"strings"
1314

@@ -171,7 +172,7 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
171172

172173
// ComposeGoGetImport returns go-get-import meta content.
173174
func ComposeGoGetImport(owner, repo string) string {
174-
return path.Join(setting.Domain, setting.AppSubURL, owner, repo)
175+
return path.Join(setting.Domain, setting.AppSubURL, url.QueryEscape(owner), url.QueryEscape(repo))
175176
}
176177

177178
// EarlyResponseForGoGetMeta responses appropriate go-get meta with status 200

0 commit comments

Comments
 (0)