Skip to content

Commit ca6f589

Browse files
author
jguerreiro
committed
fix(bitbucket): escape bitbucket tokens
1 parent ff6b4ba commit ca6f589

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

provider/bitbucket.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,13 @@ func (p *BitbucketProvider) Gather(user string) ([]GitRepository, error) {
177177
// CloneRepository clones a Github repository given the token. The token must have the `read_repository` rights.
178178
func (p *BitbucketProvider) CloneRepository(cloner cloner.Cloner,
179179
repository GitRepository) (string, error) {
180-
url := repository.GetHTTPUrl()
180+
authURL := repository.GetHTTPUrl()
181181
// If token doesn't exist, don't try to basic auth
182182
if p.token != "" {
183-
url = strings.Replace(url, "https://", fmt.Sprintf("https://%s:%s@", p.transport.user, p.token), 1)
183+
authURL = strings.Replace(authURL,
184+
"https://", fmt.Sprintf("https://%s:%s@",
185+
p.transport.user, url.QueryEscape(p.token)), 1)
184186
}
185187

186-
return cloner.CloneRepository(url)
188+
return cloner.CloneRepository(authURL)
187189
}

0 commit comments

Comments
 (0)