diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 404943d720302f5378dc8b251a872e31a8819bdb..11c346926ce84c4cc27bae278dfd282fccbf1300 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -18,7 +18,7 @@ def match?(path) 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 b7a53353a924ffc8183fa23a9bedb6ec4cf0a355..d91a857d1812c084fccc2bd90ffe0f950692934f 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -35,6 +35,10 @@ def test_served_static_file_with_non_english_filename 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 0000000000000000000000000000000000000000..92c0ad9ac92815268920ec745e0b2b73c47bea32 --- /dev/null +++ b/actionpack/test/fixtures/public/foo/foo+bar.html @@ -0,0 +1 @@ +foo+bar