aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@plataformatec.com.br>2012-02-17 01:42:06 -0800
committerJosé Valim <jose.valim@plataformatec.com.br>2012-02-17 01:42:06 -0800
commit4bb6ed7744c482dad6b71cffc19a0c86b730b730 (patch)
tree4aa9ce75aa96831ddf1c153799f9c83d8236a12d
parentdecafdd57a2c992a15df894cc43cd0a7ff6ea985 (diff)
parentd07b2f3e295031b4a2b6a3f8c80d7e92a78329c2 (diff)
downloadrails-4bb6ed7744c482dad6b71cffc19a0c86b730b730.tar.gz
rails-4bb6ed7744c482dad6b71cffc19a0c86b730b730.tar.bz2
rails-4bb6ed7744c482dad6b71cffc19a0c86b730b730.zip
Merge pull request #5066 from lest/patch-1
escape static file path to prevent double unescaping
-rw-r--r--actionpack/lib/action_dispatch/middleware/static.rb2
-rw-r--r--actionpack/test/dispatch/static_test.rb4
-rw-r--r--actionpack/test/fixtures/public/foo/foo+bar.html1
3 files changed, 6 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb
index 404943d720..11c346926c 100644
--- a/actionpack/lib/action_dispatch/middleware/static.rb
+++ b/actionpack/lib/action_dispatch/middleware/static.rb
@@ -18,7 +18,7 @@ module ActionDispatch
match = matches.detect { |m| File.file?(m) }
if match
match.sub!(@compiled_root, '')
- match
+ ::Rack::Utils.escape(match)
end
end
diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb
index b7a53353a9..d91a857d18 100644
--- a/actionpack/test/dispatch/static_test.rb
+++ b/actionpack/test/dispatch/static_test.rb
@@ -35,6 +35,10 @@ module StaticTests
assert_html "means hello in Japanese\n", get("/foo/#{Rack::Utils.escape("こんにちは.html")}")
end
+ def test_serves_static_file_with_plus_in_filename
+ assert_html "foo+bar\n", get('/foo/foo%2Bbar.html')
+ end
+
private
def assert_html(body, response)
diff --git a/actionpack/test/fixtures/public/foo/foo+bar.html b/actionpack/test/fixtures/public/foo/foo+bar.html
new file mode 100644
index 0000000000..92c0ad9ac9
--- /dev/null
+++ b/actionpack/test/fixtures/public/foo/foo+bar.html
@@ -0,0 +1 @@
+foo+bar