diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-30 11:39:46 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-30 11:39:46 -0700 |
commit | c6f9518e243de02c1bc7627184771189bdaaadaf (patch) | |
tree | 1f9c334baa743ab4dcaa2efc0fb28466c6b6a45a /actionpack/lib/action_dispatch | |
parent | d20f7b043a537b57ff4a7911f65de2fb7b7aea7d (diff) | |
parent | d1123f2056eff3696ae76e5116a6ab53e6c33f57 (diff) | |
download | rails-c6f9518e243de02c1bc7627184771189bdaaadaf.tar.gz rails-c6f9518e243de02c1bc7627184771189bdaaadaf.tar.bz2 rails-c6f9518e243de02c1bc7627184771189bdaaadaf.zip |
Merge branch 'master-sec'
* master-sec:
FileHandler should not be called for files outside the root
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index e66c21ef85..002bf8b11a 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -24,9 +24,19 @@ module ActionDispatch path = URI.parser.unescape(path) return false unless path.valid_encoding? - paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"] + paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"].map { |v| + Rack::Utils.clean_path_info v + } - if match = paths.detect {|p| File.file?(File.join(@root, p)) } + if match = paths.detect { |p| + path = File.join(@root, p) + begin + File.file?(path) && File.readable?(path) + rescue SystemCallError + false + end + + } return ::Rack::Utils.escape(match) end end |