Skip to content

Commit a465347

Browse files
committed
Fix test
1 parent 989d0ef commit a465347

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

modules/storage/local.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package storage
77
import (
88
"context"
99
"errors"
10-
"fmt"
1110
"io"
1211
"net/url"
1312
"os"
@@ -121,7 +120,7 @@ func (l *LocalStorage) Stat(path string) (os.FileInfo, error) {
121120

122121
func isLocalPathValid(path string) bool {
123122
a := filepath.Clean(path)
124-
if strings.HasPrefix(a, fmt.Sprintf("..%c", filepath.Separator)) {
123+
if strings.HasPrefix(a, "../") || strings.HasPrefix(a, "..\\") {
125124
return false
126125
}
127126
return a == path

modules/storage/local_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ func TestLocalPathIsValid(t *testing.T) {
2727
"b/../a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
2828
false,
2929
},
30+
{
31+
"..\\a/0/a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a14",
32+
false,
33+
},
3034
}
3135

3236
for _, k := range kases {

0 commit comments

Comments
 (0)