diff options
author | Andrew White <andrew.white@unboxed.co> | 2018-03-21 16:33:36 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2018-03-22 04:23:49 +0000 |
commit | 2ef145883348e92c9e6393ece9b6967e3a5a80c7 (patch) | |
tree | 0bc7a1fa19ce01b25a1e692c821aa37158355ec5 /actionpack/lib | |
parent | 4c9c3ffc2e80155f31dbcf80591618ed1c858685 (diff) | |
download | rails-2ef145883348e92c9e6393ece9b6967e3a5a80c7.tar.gz rails-2ef145883348e92c9e6393ece9b6967e3a5a80c7.tar.bz2 rails-2ef145883348e92c9e6393ece9b6967e3a5a80c7.zip |
Use ASCII-8BIT paths in ActionDispatch::Static
The rack gem returns PATH_INFO as an ASCII-8BIT encoded string but it
was being converted to US-ASCII by the match? method because it was
calling Rack::Utils.escape_path. To prevent incompatibile encoding
warnings use ASCII-8BIT strings for the root path and let Ruby handle
any filename encoding conversion.
Fixes #32294, Closes #32314.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 23492e14eb..acd999444a 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -16,7 +16,7 @@ module ActionDispatch # does not exist, a 404 "File not Found" response will be returned. class FileHandler def initialize(root, index: "index", headers: {}) - @root = root.chomp("/") + @root = root.chomp("/").b @file_server = ::Rack::File.new(@root, headers) @index = index end @@ -35,7 +35,7 @@ module ActionDispatch paths = [path, "#{path}#{ext}", "#{path}/#{@index}#{ext}"] if match = paths.detect { |p| - path = File.join(@root, p.dup.force_encoding(Encoding::UTF_8)) + path = File.join(@root, p.b) begin File.file?(path) && File.readable?(path) rescue SystemCallError @@ -43,7 +43,7 @@ module ActionDispatch end } - return ::Rack::Utils.escape_path(match) + return ::Rack::Utils.escape_path(match).b end end |