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 @@ -122,8 +122,9 @@ def can_serve(path)
122
122
123
123
def call ( env )
124
124
path = env [ PATH_INFO ]
125
+ actual_path = Utils . clean_path_info ( Utils . unescape_path ( path ) )
125
126
126
- if can_serve ( path )
127
+ if can_serve ( actual_path )
127
128
if overwrite_file_path ( path )
128
129
env [ PATH_INFO ] = ( add_index_root? ( path ) ? path + @index : @urls [ path ] )
129
130
elsif @gzip && env [ 'HTTP_ACCEPT_ENCODING' ] && /\b gzip\b / . match? ( env [ 'HTTP_ACCEPT_ENCODING' ] )
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ def static(app, *args)
43
43
res . body . must_match ( /ruby/ )
44
44
end
45
45
46
+ it "does not serve files outside :urls" do
47
+ res = @request . get ( "/cgi/../#{ File . basename ( __FILE__ ) } " )
48
+ res . must_be :ok?
49
+ res . body . must_equal "Hello World"
50
+ end
51
+
46
52
it "404s if url root is known but it can't find the file" do
47
53
res = @request . get ( "/cgi/foo" )
48
54
res . must_be :not_found?
You can’t perform that action at this time.
0 commit comments