pathutil: check both styles of os.PathSeparator (#7020)

This commit is contained in:
Joe Chen
2022-06-07 20:34:46 +08:00
committed by GitHub
parent 325904ce5a
commit 2ca014250f
3 changed files with 51 additions and 17 deletions

View File

@@ -9,7 +9,9 @@ import (
"strings"
)
// Clean cleans up given path and returns a relative path that goes straight down.
// Clean cleans up given path and returns a relative path that goes straight
// down to prevent path traversal.
func Clean(p string) string {
p = strings.ReplaceAll(p, `\`, "/")
return strings.Trim(path.Clean("/"+p), "/")
}