summaryrefslogtreecommitdiffstats
path: root/utils/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'utils/path.go')
-rw-r--r--utils/path.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/utils/path.go b/utils/path.go
new file mode 100644
index 000000000..5f921b41d
--- /dev/null
+++ b/utils/path.go
@@ -0,0 +1,15 @@
+// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package utils
+
+import (
+ "path/filepath"
+ "strings"
+)
+
+// PathTraversesUpward will return true if the path attempts to traverse upwards by using
+// ".." in the path.
+func PathTraversesUpward(path string) bool {
+ return strings.HasPrefix(filepath.Clean(path), "..")
+}