summaryrefslogtreecommitdiffstats
path: root/modules/storage/local_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-03-14 23:18:27 +0800
committerGitHub <noreply@github.com>2022-03-14 16:18:27 +0100
commit49db87a035a28cd8eaa4abdd5832f952ca6449d9 (patch)
tree231676f5ca713844297cc16a52700fc50c8712fb /modules/storage/local_test.go
parent3ad6cf20695ea4e56e00427c6af76efc25e9b670 (diff)
downloadgitea-49db87a035a28cd8eaa4abdd5832f952ca6449d9.tar.gz
gitea-49db87a035a28cd8eaa4abdd5832f952ca6449d9.zip
Fix lfs bug (#19072)
* Fix lfs bug
Diffstat (limited to 'modules/storage/local_test.go')
-rw-r--r--modules/storage/local_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/storage/local_test.go b/modules/storage/local_test.go
new file mode 100644
index 0000000000..8714f37f0d
--- /dev/null
+++ b/modules/storage/local_test.go
@@ -0,0 +1,45 @@
+// Copyright 2022 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package storage
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestLocalPathIsValid(t *testing.T) {
+ kases := []struct {
+ path string
+ valid bool
+ }{
+ {
+ "a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
+ true,
+ },
+ {
+ "../a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
+ false,
+ },
+ {
+ "a\\0\\a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
+ true,
+ },
+ {
+ "b/../a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
+ false,
+ },
+ {
+ "..\\a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
+ false,
+ },
+ }
+
+ for _, k := range kases {
+ t.Run(k.path, func(t *testing.T) {
+ assert.EqualValues(t, k.valid, isLocalPathValid(k.path))
+ })
+ }
+}