From 55cac81bc50b7b825e12e1c42edda398094d67ef Mon Sep 17 00:00:00 2001 From: Michael Reinsch Date: Thu, 8 Mar 2012 20:26:10 +0900 Subject: fix ArgumentError being raised in case of invalid byte sequences --- actionpack/lib/action_dispatch/middleware/static.rb | 1 + actionpack/test/dispatch/static_test.rb | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 31185fec07..ad11b6a211 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -38,6 +38,7 @@ module ActionDispatch end def escape_glob_chars(path) + path.force_encoding('binary') if path.respond_to? :force_encoding path.gsub(/[*?{}\[\]]/, "\\\\\\&") end end diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index 949deefa9d..856746c451 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -6,6 +6,10 @@ module StaticTests assert_equal "Hello, World!", get("/nofile").body end + def test_handles_urls_with_bad_encoding + assert_equal "Hello, World!", get("/doorkeeper%E3E4").body + end + def test_sets_cache_control response = get("/index.html") assert_html "/index.html", response -- cgit v1.2.3