File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
2020 "runtime"
2121 "strings"
2222 "testing"
23+ "testing/fstest"
2324 "time"
2425
2526 "github.com/stretchr/testify/assert"
@@ -133,6 +134,11 @@ func TestNewDefaultFS(t *testing.T) {
133134}
134135
135136func TestEcho_StaticFS (t * testing.T ) {
137+ dotsInFilenameFS := fstest.MapFS {
138+ // On Windows filename `%2f..` can not be created but in Linux it is possible.
139+ "%2f.." : {Data : []byte ("This filename is escaped to `/..` in URL.Path" )},
140+ }
141+
136142 var testCases = []struct {
137143 givenFs fs.FS
138144 name string
@@ -280,12 +286,12 @@ func TestEcho_StaticFS(t *testing.T) {
280286 {
281287 name : "possible open redirect vulnerability when not unescaping path variables in static handler" ,
282288 givenPrefix : "/" ,
283- givenFs : os . DirFS ( "_fixture/dist/" ) ,
289+ givenFs : dotsInFilenameFS ,
284290 givenEnablePathUnescapingStaticFiles : false ,
285291 whenURL : "/%2f.." ,
286292 expectStatus : http .StatusOK ,
287293 expectHeaderLocation : "" ,
288- expectBodyStartsWith : "This filename is escaped to `/..` in URL.Path\n " ,
294+ expectBodyStartsWith : "This filename is escaped to `/..` in URL.Path" ,
289295 },
290296 }
291297
You can’t perform that action at this time.
0 commit comments