Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean Path in Options #23006

Merged
merged 4 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/options/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ func WalkLocales(callback func(path, name string, d fs.DirEntry, err error) erro

// Readme reads the content of a specific readme from static or custom path.
func Readme(name string) ([]byte, error) {
return fileFromDir(path.Join("readme", name))
return fileFromDir(path.Join("readme", path.Clean("/"+name)))
}

// Gitignore reads the content of a specific gitignore from static or custom path.
func Gitignore(name string) ([]byte, error) {
return fileFromDir(path.Join("gitignore", name))
return fileFromDir(path.Join("gitignore", path.Clean("/"+name)))
}

// License reads the content of a specific license from static or custom path.
func License(name string) ([]byte, error) {
return fileFromDir(path.Join("license", name))
return fileFromDir(path.Join("license", path.Clean("/"+name)))
}

// Labels reads the content of a specific labels from static or custom path.
func Labels(name string) ([]byte, error) {
return fileFromDir(path.Join("label", name))
return fileFromDir(path.Join("label", path.Clean("/"+name)))
}

// fileFromDir is a helper to read files from static or custom path.
Expand Down
8 changes: 4 additions & 4 deletions modules/options/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,22 @@ func WalkLocales(callback func(path, name string, d fs.DirEntry, err error) erro

// Readme reads the content of a specific readme from bindata or custom path.
func Readme(name string) ([]byte, error) {
return fileFromDir(path.Join("readme", name))
return fileFromDir(path.Join("readme", path.Clean("/"+name)))
}

// Gitignore reads the content of a gitignore locale from bindata or custom path.
func Gitignore(name string) ([]byte, error) {
return fileFromDir(path.Join("gitignore", name))
return fileFromDir(path.Join("gitignore", path.Clean("/"+name)))
}

// License reads the content of a specific license from bindata or custom path.
func License(name string) ([]byte, error) {
return fileFromDir(path.Join("license", name))
return fileFromDir(path.Join("license", path.Clean("/"+name)))
}

// Labels reads the content of a specific labels from static or custom path.
func Labels(name string) ([]byte, error) {
return fileFromDir(path.Join("label", name))
return fileFromDir(path.Join("label", path.Clean("/"+name)))
}

// fileFromDir is a helper to read files from bindata or custom path.
Expand Down