http://github.com/rack/rack/commits/nosqueeze
Thanks,
Ryan
From 67f7f9b4ee1907b2db0e6addc0ad65f7d53916f4 Mon Sep 17 00:00:00 2001
From: Ryan Tomayko <rtom...@gmail.com>
Date: Tue, 22 Dec 2009 15:19:22 -0800
Subject: [PATCH 1/2] Failing testcase for URLMap squeeze issue
---
test/spec_rack_urlmap.rb | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/test/spec_rack_urlmap.rb b/test/spec_rack_urlmap.rb
index 6c4d72a..93ef98b 100644
--- a/test/spec_rack_urlmap.rb
+++ b/test/spec_rack_urlmap.rb
@@ -182,4 +182,28 @@ context "Rack::URLMap" do
res["X-PathInfo"].should.equal "/"
res["X-ScriptName"].should.equal ""
end
+
+ specify "should not squeeze slashes" do
+ map = Rack::URLMap.new("/" => lambda { |env|
+ [200,
+ { "Content-Type" => "text/plain",
+ "X-Position" => "root",
+ "X-PathInfo" => env["PATH_INFO"],
+ "X-ScriptName" => env["SCRIPT_NAME"]
+ }, [""]]},
+ "/foo" => lambda { |env|
+ [200,
+ { "Content-Type" => "text/plain",
+ "X-Position" => "foo",
+ "X-PathInfo" => env["PATH_INFO"],
+ "X-ScriptName" => env["SCRIPT_NAME"]
+ }, [""]]}
+ )
+
+ res = Rack::MockRequest.new(map).get("/http://example.org/bar")
+ res.should.be.ok
+ res["X-Position"].should.equal "root"
+ res["X-PathInfo"].should.equal "/http://example.org/bar"
+ res["X-ScriptName"].should.equal ""
+ end
end
--
1.6.4
From 19b12b29f74d9cf61e29ace4a4d47feef46e590e Mon Sep 17 00:00:00 2001
From: Ricardo Chimal, Jr <ric...@heroku.com>
Date: Wed, 28 Oct 2009 19:16:29 -0700
Subject: [PATCH 2/2] Don't munge PATH_INFO in URLMap
---
lib/rack/urlmap.rb | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/rack/urlmap.rb b/lib/rack/urlmap.rb
index fcf6616..4dd1bec 100644
--- a/lib/rack/urlmap.rb
+++ b/lib/rack/urlmap.rb
@@ -34,7 +34,7 @@ module Rack
end
def call(env)
- path = env["PATH_INFO"].to_s.squeeze("/")
+ path = env["PATH_INFO"].to_s
script_name = env['SCRIPT_NAME']
hHost, sName, sPort =
env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT')
@mapping.each { |host, location, app|
--
1.6.4
... to allow requests like http://example.org/bar//baz, which can happen
due to sloppy URL editing or cheap generation.
Not sure what the exact semantics of //+ are, actually.
--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org
I see. I wonder if maybe that would be more appropriate in a separate
SlashSqueezing middleware or whatever. Another approach would be to
use a squeezed version of PATH_INFO in URLMap but to not overwrite the
env's PATH_INFO -- use the squeezed version purely to locate the
downstream handler.
> Not sure what the exact semantics of //+ are, actually.
Hmm. Me neither now that you mention it. You mean, does "/foo//bar" ==
"/bar" or "/foo/bar" or "/foo//bar"? I'll see what I can dig up.
Thanks,
Ryan
--
# tomayko.com/about
+1