diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-15 10:14:01 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-03-15 10:14:01 -0700 |
commit | 8f5f92cf8e96314e96ce38a6c60c64a40c27ae49 (patch) | |
tree | a74d1e42142278f0715f963cc3ce830038124bff /actionpack | |
parent | ee8e567d50f75c91d422c697845bc1a84f9114be (diff) | |
parent | 7d5fbf846b432821d0179553fa902d2de9372172 (diff) | |
download | rails-8f5f92cf8e96314e96ce38a6c60c64a40c27ae49.tar.gz rails-8f5f92cf8e96314e96ce38a6c60c64a40c27ae49.tar.bz2 rails-8f5f92cf8e96314e96ce38a6c60c64a40c27ae49.zip |
Merge pull request #5337 from mreinsch/static_invalid_byte_sequence
fix ArgumentError being raised in case of invalid byte sequences
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 1 | ||||
-rw-r--r-- | actionpack/test/dispatch/static_test.rb | 4 |
2 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 63b7422287..9073e6582d 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -39,6 +39,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 092ca3e20a..112f470786 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -7,6 +7,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 |