File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,6 +257,24 @@ func TestEcho_StaticFS(t *testing.T) {
257257 expectStatus : http .StatusNotFound ,
258258 expectBodyStartsWith : "{\" message\" :\" Not Found\" }\n " ,
259259 },
260+ {
261+ name : "do not accept encoded dots in path (%2E%2E is `..`) to traverse within filesystem boundary" ,
262+ givenPrefix : "/" ,
263+ givenFs : os .DirFS ("_fixture/" ),
264+ givenEnablePathUnescapingStaticFiles : false ,
265+ whenURL : `/dist/public/%2E%2E/private.txt` , // `/dist/public/../private.txt`
266+ expectStatus : http .StatusNotFound ,
267+ expectBodyStartsWith : "{\" message\" :\" Not Found\" }\n " ,
268+ },
269+ {
270+ name : "allow encoded dots in path (%2E%2E is `..`) to traverse within filesystem" ,
271+ givenPrefix : "/" ,
272+ givenFs : os .DirFS ("_fixture/" ),
273+ givenEnablePathUnescapingStaticFiles : true ,
274+ whenURL : `/dist/public/%2E%2E/private.txt` , // `/dist/public/../private.txt`
275+ expectStatus : http .StatusOK ,
276+ expectBodyStartsWith : "private file" ,
277+ },
260278 {
261279 name : "do not allow directory traversal (slash - unix separator)" ,
262280 givenPrefix : "/" ,
You can’t perform that action at this time.
0 commit comments