Skip to content

Commit

Permalink
download: Actually validate empty pathnames
Browse files Browse the repository at this point in the history
From the path module doc:
    If the path is empty, Base returns ".". If the path consists
    entirely of slashes, Base returns "/".

Actually validate that we provide a filename when one is required,
rather than failing with an error that /scratch exists but is not a
file.

Signed-off-by: Daniel Stone <[email protected]>
  • Loading branch information
fooishbar committed May 13, 2024
1 parent e8bc216 commit ecbea7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion actions/download_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (d *DownloadAction) validateFilename(context *debos.DebosContext, url *url.
} else {
filename = path.Base(d.Filename)
}
if len(filename) == 0 {
if len(filename) == 0 || filename == "." || filename == "/" {
return "", fmt.Errorf("Incorrect filename is provided for '%s'", d.Url)
}
filename = path.Join(context.Scratchdir, filename)
Expand Down

0 comments on commit ecbea7a

Please sign in to comment.