diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index a20253676e671..f9b3714b8fb90 100644 --- a/modules/options/dynamic.go +++ b/modules/options/dynamic.go @@ -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. diff --git a/modules/options/static.go b/modules/options/static.go index ff3c86d3f84f6..2405d658bfb17 100644 --- a/modules/options/static.go +++ b/modules/options/static.go @@ -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.