提交 4bb6ed77 编写于 作者: J José Valim

Merge pull request #5066 from lest/patch-1

escape static file path to prevent double unescaping
...@@ -18,7 +18,7 @@ def match?(path) ...@@ -18,7 +18,7 @@ def match?(path)
match = matches.detect { |m| File.file?(m) } match = matches.detect { |m| File.file?(m) }
if match if match
match.sub!(@compiled_root, '') match.sub!(@compiled_root, '')
match ::Rack::Utils.escape(match)
end end
end end
......
...@@ -35,6 +35,10 @@ def test_served_static_file_with_non_english_filename ...@@ -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")}") assert_html "means hello in Japanese\n", get("/foo/#{Rack::Utils.escape("こんにちは.html")}")
end end
def test_serves_static_file_with_plus_in_filename
assert_html "foo+bar\n", get('/foo/foo%2Bbar.html')
end
private private
def assert_html(body, response) def assert_html(body, response)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册