fix: replace colons in addition to slashes in app tmp directory (#6290) (#6293)

closes https://github.com/argoproj/argo-cd/issues/6290

Signed-off-by: Blake Barnett <blakeb@me.com>
This commit is contained in:
blakebarnett 2021-05-24 13:04:29 -07:00 committed by GitHub
parent ffb22ff1ff
commit ae5388dd79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
@ -120,7 +121,8 @@ func WithEventHandlers(handlers EventHandlers) ClientOpts {
}
func NewClient(rawRepoURL string, creds Creds, insecure bool, enableLfs bool, opts ...ClientOpts) (Client, error) {
root := filepath.Join(os.TempDir(), strings.Replace(NormalizeGitURL(rawRepoURL), "/", "_", -1))
r := regexp.MustCompile("(/|:)")
root := filepath.Join(os.TempDir(), r.ReplaceAllString(NormalizeGitURL(rawRepoURL), "_"))
if root == os.TempDir() {
return nil, fmt.Errorf("Repository '%s' cannot be initialized, because its root would be system temp at %s", rawRepoURL, root)
}