Permalink
Browse files

fix ArgumentError being raised in case of invalid byte sequences

  • Loading branch information...
1 parent 9bcd662 commit 55cac81bc50b7b825e12e1c42edda398094d67ef @mreinsch mreinsch committed Mar 8, 2012
Showing with 5 additions and 0 deletions.
  1. +1 −0 actionpack/lib/action_dispatch/middleware/static.rb
  2. +4 −0 actionpack/test/dispatch/static_test.rb
View
1 actionpack/lib/action_dispatch/middleware/static.rb
@@ -38,6 +38,7 @@ def unescape_path(path)
end
def escape_glob_chars(path)
+ path.force_encoding('binary') if path.respond_to? :force_encoding
path.gsub(/[*?{}\[\]]/, "\\\\\\&")
end
end
View
4 actionpack/test/dispatch/static_test.rb
@@ -6,6 +6,10 @@ def test_serves_dynamic_content
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

0 comments on commit 55cac81

Please sign in to comment.