diff options
author | Joe Chen <jc@unknwon.io> | 2022-06-07 20:34:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 20:34:46 +0800 |
commit | 2ca014250fbf0bba94c914d9e43b1f6d8eca3bb0 (patch) | |
tree | adfa9aa312ce21c2e07c9cac92a6d25c0cb94e96 /internal/pathutil/pathutil.go | |
parent | 325904ce5a8579434618dfaea8ad5dd973965fcc (diff) |
pathutil: check both styles of `os.PathSeparator` (#7020)
Diffstat (limited to 'internal/pathutil/pathutil.go')
-rw-r--r-- | internal/pathutil/pathutil.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/internal/pathutil/pathutil.go b/internal/pathutil/pathutil.go index 6a7286e1..26ea76b6 100644 --- a/internal/pathutil/pathutil.go +++ b/internal/pathutil/pathutil.go @@ -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), "/") } |