mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 19:24:10 +01:00
Fix go-get URL generation (#5905)
This commit is contained in:
parent
57a69ef277
commit
80098bd752
3 changed files with 5 additions and 3 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
|
@ -834,7 +835,7 @@ type CloneLink struct {
|
||||||
|
|
||||||
// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
|
// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
|
||||||
func ComposeHTTPSCloneURL(owner, repo string) string {
|
func ComposeHTTPSCloneURL(owner, repo string) string {
|
||||||
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
|
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, url.QueryEscape(owner), url.QueryEscape(repo))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) cloneLink(e Engine, isWiki bool) *CloneLink {
|
func (repo *Repository) cloneLink(e Engine, isWiki bool) *CloneLink {
|
||||||
|
|
|
@ -209,7 +209,7 @@ func Contexter() macaron.Handler {
|
||||||
if err == nil && len(repo.DefaultBranch) > 0 {
|
if err == nil && len(repo.DefaultBranch) > 0 {
|
||||||
branchName = repo.DefaultBranch
|
branchName = repo.DefaultBranch
|
||||||
}
|
}
|
||||||
prefix := setting.AppURL + path.Join(ownerName, repoName, "src", "branch", branchName)
|
prefix := setting.AppURL + path.Join(url.QueryEscape(ownerName), url.QueryEscape(repoName), "src", "branch", branchName)
|
||||||
c.Header().Set("Content-Type", "text/html")
|
c.Header().Set("Content-Type", "text/html")
|
||||||
c.WriteHeader(http.StatusOK)
|
c.WriteHeader(http.StatusOK)
|
||||||
c.Write([]byte(com.Expand(`<!doctype html>
|
c.Write([]byte(com.Expand(`<!doctype html>
|
||||||
|
|
|
@ -8,6 +8,7 @@ package context
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
|
||||||
|
|
||||||
// ComposeGoGetImport returns go-get-import meta content.
|
// ComposeGoGetImport returns go-get-import meta content.
|
||||||
func ComposeGoGetImport(owner, repo string) string {
|
func ComposeGoGetImport(owner, repo string) string {
|
||||||
return path.Join(setting.Domain, setting.AppSubURL, owner, repo)
|
return path.Join(setting.Domain, setting.AppSubURL, url.QueryEscape(owner), url.QueryEscape(repo))
|
||||||
}
|
}
|
||||||
|
|
||||||
// EarlyResponseForGoGetMeta responses appropriate go-get meta with status 200
|
// EarlyResponseForGoGetMeta responses appropriate go-get meta with status 200
|
||||||
|
|
Loading…
Reference in a new issue