aboutsummaryrefslogtreecommitdiff
path: root/internal/pathutil/pathutil.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-06-07 20:34:46 +0800
committerGitHub <noreply@github.com>2022-06-07 20:34:46 +0800
commit2ca014250fbf0bba94c914d9e43b1f6d8eca3bb0 (patch)
treeadfa9aa312ce21c2e07c9cac92a6d25c0cb94e96 /internal/pathutil/pathutil.go
parent325904ce5a8579434618dfaea8ad5dd973965fcc (diff)
pathutil: check both styles of `os.PathSeparator` (#7020)
Diffstat (limited to 'internal/pathutil/pathutil.go')
-rw-r--r--internal/pathutil/pathutil.go4
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), "/")
}