diff options
author | James Tucker <jftucker@gmail.com> | 2014-07-06 13:29:37 -0700 |
---|---|---|
committer | James Tucker <jftucker@gmail.com> | 2014-07-06 13:29:37 -0700 |
commit | 72f58e68d51759f38215f72f8e9748a4da218fa3 (patch) | |
tree | c2878c5c307a24d3d91b341140188df0c74f8d04 | |
parent | 4da6ef9f5b6a98c289ab84fe789bf32137001b9d (diff) | |
parent | c2564e3d8235c5fd95e312aa6c97f120904f4686 (diff) | |
download | rack-72f58e68d51759f38215f72f8e9748a4da218fa3.tar.gz |
Merge pull request #675 from keithduncan/fix-clean-path-for-slash
Fix `clean_path_info` for paths with only a slash
-rw-r--r-- | lib/rack/utils.rb | 2 | ||||
-rw-r--r-- | test/spec_utils.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb index 1be818b4..264b6b62 100644 --- a/lib/rack/utils.rb +++ b/lib/rack/utils.rb @@ -639,7 +639,7 @@ module Rack part == '..' ? clean.pop : clean << part end - clean.unshift '/' if parts.first.empty? + clean.unshift '/' if parts.empty? || parts.first.empty? ::File.join(*clean) end diff --git a/test/spec_utils.rb b/test/spec_utils.rb index 38ffc861..de12f83d 100644 --- a/test/spec_utils.rb +++ b/test/spec_utils.rb @@ -409,6 +409,10 @@ describe Rack::Utils do should "not clean directory traversal with encoded periods" do Rack::Utils.clean_path_info("/%2E%2E/README").should.equal "/%2E%2E/README" end + + should "clean slash only paths" do + Rack::Utils.clean_path_info("/").should.equal "/" + end end describe Rack::Utils, "byte_range" do |