mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
validate expanded path matches public_dir when serving static files
This commit is contained in:
parent
ed2add3785
commit
462c3ca1db
2 changed files with 2 additions and 0 deletions
|
@ -1090,6 +1090,7 @@ module Sinatra
|
|||
return unless valid_path?(path)
|
||||
|
||||
path = File.expand_path(path)
|
||||
return unless path.start_with?(File.expand_path(public_dir) + '/')
|
||||
return unless File.file?(path)
|
||||
|
||||
env['sinatra.static_file'] = path
|
||||
|
|
|
@ -97,6 +97,7 @@ class StaticTest < Minitest::Test
|
|||
mock_app do
|
||||
set :static, true
|
||||
set :public_folder, __dir__ + '/data'
|
||||
disable :protection
|
||||
end
|
||||
get "/../#{File.basename(__FILE__)}"
|
||||
assert not_found?
|
||||
|
|
Loading…
Add table
Reference in a new issue