summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-05-07 15:25:52 +0100
committerGitHub <noreply@github.com>2020-05-07 11:25:52 -0300
commit71e73db2ff1a1599391da22732ad30895d837ba0 (patch)
tree2e4a327dd537f03a7070da4a66282abb80a64ffc /modules
parent507d0ec57aaf02a60a3de8aca3e635616b592fc5 (diff)
downloadgitea-71e73db2ff1a1599391da22732ad30895d837ba0.tar.gz
gitea-71e73db2ff1a1599391da22732ad30895d837ba0.zip
Manage port in submodule refurl (#11305)
* Manage port in submodule refurl Fix #11304 Signed-off-by: Andrew Thornton <art27@cantab.net> * fix lint Signed-off-by: Andrew Thornton <art27@cantab.net> * URLJoin is causes a cyclic dependency and possibly isn't what what we want anyway Signed-off-by: Andrew Thornton <art27@cantab.net> * Protect against leading .. in scp syntax Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/submodule.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/git/submodule.go b/modules/git/submodule.go
index 2527eac810..222a5e4f8c 100644
--- a/modules/git/submodule.go
+++ b/modules/git/submodule.go
@@ -52,10 +52,14 @@ func getRefURL(refURL, urlPrefix, repoFullName string) string {
urlPrefixHostname = prefixURL.Host
}
+ if strings.HasSuffix(urlPrefix, "/") {
+ urlPrefix = urlPrefix[:len(urlPrefix)-1]
+ }
+
// FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules
// Relative url prefix check (according to git submodule documentation)
if strings.HasPrefix(refURI, "./") || strings.HasPrefix(refURI, "../") {
- return urlPrefix + path.Clean(path.Join(repoFullName, refURI))
+ return urlPrefix + path.Clean(path.Join("/", repoFullName, refURI))
}
if !strings.Contains(refURI, "://") {
@@ -73,7 +77,7 @@ func getRefURL(refURL, urlPrefix, repoFullName string) string {
}
if urlPrefixHostname == refHostname {
- return prefixURL.Scheme + "://" + urlPrefixHostname + path.Join(prefixURL.Path, path.Clean(pth))
+ return urlPrefix + path.Clean(path.Join("/", pth))
}
return "http://" + refHostname + pth
}
@@ -94,7 +98,7 @@ func getRefURL(refURL, urlPrefix, repoFullName string) string {
for _, scheme := range supportedSchemes {
if ref.Scheme == scheme {
if urlPrefixHostname == refHostname {
- return prefixURL.Scheme + "://" + prefixURL.Host + path.Join(prefixURL.Path, ref.Path)
+ return urlPrefix + path.Clean(path.Join("/", ref.Path))
} else if ref.Scheme == "http" || ref.Scheme == "https" {
if len(ref.User.Username()) > 0 {
return ref.Scheme + "://" + fmt.Sprintf("%v", ref.User) + "@" + ref.Host + ref.Path