File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -124,8 +124,9 @@ def can_serve(path)
124124
125125 def call ( env )
126126 path = env [ PATH_INFO ]
127+ actual_path = Utils . clean_path_info ( Utils . unescape_path ( path ) )
127128
128- if can_serve ( path )
129+ if can_serve ( actual_path )
129130 if overwrite_file_path ( path )
130131 env [ PATH_INFO ] = ( add_index_root? ( path ) ? path + @index : @urls [ path ] )
131132 elsif @gzip && env [ 'HTTP_ACCEPT_ENCODING' ] && /\b gzip\b / . match? ( env [ 'HTTP_ACCEPT_ENCODING' ] )
Original file line number Diff line number Diff line change @@ -49,6 +49,12 @@ def static(app, *args)
4949 res . body . must_match ( /ruby/ )
5050 end
5151
52+ it "does not serve files outside :urls" do
53+ res = @request . get ( "/cgi/../#{ File . basename ( __FILE__ ) } " )
54+ res . must_be :ok?
55+ res . body . must_equal "Hello World"
56+ end
57+
5258 it "404s if url root is known but it can't find the file" do
5359 res = @request . get ( "/cgi/foo" )
5460 res . must_be :not_found?
You can’t perform that action at this time.
0 commit comments