@@ -1097,6 +1097,17 @@ describe('send(file, options)', function(){
10971097 . expect ( 200 , 'tobi' , done )
10981098 } )
10991099
1100+ it ( 'should with with trailing slash' , function ( done ) {
1101+ var app = http . createServer ( function ( req , res ) {
1102+ send ( req , req . url , { root : __dirname + '/fixtures/' } )
1103+ . pipe ( res ) ;
1104+ } ) ;
1105+
1106+ request ( app )
1107+ . get ( '/name.txt' )
1108+ . expect ( 200 , 'tobi' , done )
1109+ } )
1110+
11001111 it ( 'should restrict paths to within root' , function ( done ) {
11011112 var app = http . createServer ( function ( req , res ) {
11021113 send ( req , req . url , { root : __dirname + '/fixtures' } )
@@ -1118,6 +1129,17 @@ describe('send(file, options)', function(){
11181129 . get ( '/pets/../../send.js' )
11191130 . expect ( 403 , done )
11201131 } )
1132+
1133+ it ( 'should not allow root transversal' , function ( done ) {
1134+ var app = http . createServer ( function ( req , res ) {
1135+ send ( req , req . url , { root : __dirname + '/fixtures/name.d' } )
1136+ . pipe ( res ) ;
1137+ } ) ;
1138+
1139+ request ( app )
1140+ . get ( '/../name.dir/name.txt' )
1141+ . expect ( 403 , done )
1142+ } )
11211143 } )
11221144
11231145 describe ( 'when missing' , function ( ) {
0 commit comments