Skip to content

Commit ab8c696

Browse files
committed
Fix test
1 parent a465347 commit ab8c696

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

modules/storage/local.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"io"
1111
"net/url"
1212
"os"
13+
"path"
1314
"path/filepath"
1415
"strings"
1516

@@ -118,12 +119,12 @@ func (l *LocalStorage) Stat(path string) (os.FileInfo, error) {
118119
return os.Stat(filepath.Join(l.dir, path))
119120
}
120121

121-
func isLocalPathValid(path string) bool {
122-
a := filepath.Clean(path)
122+
func isLocalPathValid(p string) bool {
123+
a := path.Clean(p)
123124
if strings.HasPrefix(a, "../") || strings.HasPrefix(a, "..\\") {
124125
return false
125126
}
126-
return a == path
127+
return a == p
127128
}
128129

129130
// Delete delete a file

modules/storage/local_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ func TestLocalPathIsValid(t *testing.T) {
2323
"../a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
2424
false,
2525
},
26+
{
27+
"a\\0\\a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
28+
true,
29+
},
2630
{
2731
"b/../a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
2832
false,

0 commit comments

Comments
 (0)