mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Fix PathTraversal to work against PATH_INFO in capitals
This commit is contained in:
parent
34f13c082d
commit
88cd2f0456
2 changed files with 3 additions and 3 deletions
|
@ -20,7 +20,7 @@ module Rack
|
|||
|
||||
def cleanup(path)
|
||||
parts = []
|
||||
unescaped = path.gsub('%2e', '.').gsub('%2f', '/')
|
||||
unescaped = path.gsub(/%2e/i, '.').gsub(/%2f/i, '/')
|
||||
|
||||
unescaped.split('/').each do |part|
|
||||
next if part.empty? or part == '.'
|
||||
|
|
|
@ -14,8 +14,8 @@ describe Rack::Protection::PathTraversal do
|
|||
|
||||
{ # yes, this is ugly, feel free to change that
|
||||
'/..' => '/', '/a/../b' => '/b', '/a/../b/' => '/b/', '/a/.' => '/a/',
|
||||
'/%2e.' => '/', '/a/%2e%2e/b' => '/b', '/a%2f%2e%2e%2fb/' => '/b/',
|
||||
'//' => '/', '/%2fetc%2fpasswd' => '/etc/passwd'
|
||||
'/%2e.' => '/', '/a/%2E%2e/b' => '/b', '/a%2f%2E%2e%2Fb/' => '/b/',
|
||||
'//' => '/', '/%2fetc%2Fpasswd' => '/etc/passwd'
|
||||
}.each do |a, b|
|
||||
it("replaces #{a.inspect} with #{b.inspect}") { get(a).body.should == b }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue