Skip to content

Commit

Permalink
sanitize filenames everywhere a URI is used to derive the filename
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman committed Dec 24, 2024
1 parent 0ba32ea commit bec23de
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/exec/vendor_component_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func copyComponentToDestination(atmosConfig schema.AtmosConfiguration, tempDir,
componentPath2 := componentPath
if sourceIsLocalFile {
if filepath.Ext(componentPath) == "" {
componentPath2 = filepath.Join(componentPath, filepath.Base(uri))
componentPath2 = filepath.Join(componentPath, sanitizeFileName(uri))
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/exec/vendor_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func downloadAndInstall(p *pkgAtmosVendor, dryRun bool, atmosConfig schema.Atmos
OnSymlink: func(src string) cp.SymlinkAction { return cp.Deep },
}
if p.sourceIsLocalFile {
tempDir = filepath.Join(tempDir, filepath.Base(p.uri))
tempDir = filepath.Join(tempDir, sanitizeFileName(p.uri))
}
if err := cp.Copy(p.uri, tempDir, copyOptions); err != nil {
return installedPkgMsg{
Expand Down
4 changes: 2 additions & 2 deletions internal/exec/vendor_model_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati

switch p.pkgType {
case pkgTypeRemote:
tempDir = filepath.Join(tempDir, filepath.Base(p.uri))
tempDir = filepath.Join(tempDir, sanitizeFileName(p.uri))

client := &getter.Client{
Ctx: context.Background(),
Expand Down Expand Up @@ -159,7 +159,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati

tempDir2 := tempDir
if p.sourceIsLocalFile {
tempDir2 = filepath.Join(tempDir, filepath.Base(p.uri))
tempDir2 = filepath.Join(tempDir, sanitizeFileName(p.uri))
}

if err = cp.Copy(p.uri, tempDir2, copyOptions); err != nil {
Expand Down

0 comments on commit bec23de

Please sign in to comment.