URL encode auth to avoid url issues.

This commit is contained in:
Luke Kysow
2018-07-25 14:49:47 +02:00
parent 5d43445505
commit 6e14c200f3

View File

@@ -79,9 +79,14 @@ func NewRepo(vcsHostType VCSHostType, repoFullName string, cloneURL string, vcsU
}
}
// Construct clone urls with http auth. Need to do both https and http
// because in GitLab's docs they have some http urls.
auth := fmt.Sprintf("%s:%s@", vcsUser, vcsToken)
// We url encode because we're using them in a URL and weird characters can
// mess up git.
escapedVCSUser := url.QueryEscape(vcsUser)
escapedVCSToken := url.QueryEscape(vcsToken)
auth := fmt.Sprintf("%s:%s@", escapedVCSUser, escapedVCSToken)
// Construct clone urls with http and https auth. Need to do both
// because Bitbucket supports http.
authedCloneURL := strings.Replace(cloneURL, "https://", "https://"+auth, -1)
authedCloneURL = strings.Replace(authedCloneURL, "http://", "http://"+auth, -1)