From fe7a40233f526c7ae250f54dd4c8d2b1584a2aa8 Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 20 Feb 2023 11:09:41 +0100 Subject: [PATCH 1/3] Clean Path in Options --- modules/options/dynamic.go | 8 ++++---- modules/options/static.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index a20253676e671..5465e04ab2451 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.base(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.Base(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.Base(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.Base(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..55bb4d5c9f3b8 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.Base(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.Base(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.Base(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.Base(name))) } // fileFromDir is a helper to read files from bindata or custom path. From 1ff2628be03a51be773d25e7d8eb415a1366d70e Mon Sep 17 00:00:00 2001 From: JakobDev Date: Mon, 20 Feb 2023 11:15:40 +0100 Subject: [PATCH 2/3] Fiy typo --- modules/options/dynamic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index 5465e04ab2451..479b992c86d3f 100644 --- a/modules/options/dynamic.go +++ b/modules/options/dynamic.go @@ -79,7 +79,7 @@ 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", path.base(name))) + return fileFromDir(path.Join("readme", path.Base(name))) } // Gitignore reads the content of a specific gitignore from static or custom path. From fc54a449bc05c3561b913bbb264c05f6b437af63 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Wed, 8 Mar 2023 14:00:40 +0800 Subject: [PATCH 3/3] fix: use path.Clean("/"+name) --- modules/options/dynamic.go | 8 ++++---- modules/options/static.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index 479b992c86d3f..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", path.Base(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", path.Base(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", path.Base(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", path.Base(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 55bb4d5c9f3b8..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", path.Base(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", path.Base(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", path.Base(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", path.Base(name))) + return fileFromDir(path.Join("label", path.Clean("/"+name))) } // fileFromDir is a helper to read files from bindata or custom path.