Permalink
Browse files

[Rails4 regression] prevent thin and puma cause error in Non ASCII UR…

…L on Windows

* #19187
* #19533
* macournoyer/thin#268

These are serious Rails 4 regression for Redmine Bitnami Windows users.

https://community.bitnami.com/t/problems-with-3-0-1-installation-see-report-inside/30195/

It is not caused on webrick users.

Related:

* rack/rack#732 (comment)
* phusion/passenger#1328
  • Loading branch information...
marutosi authored and rafaelfranca committed Mar 26, 2015
1 parent 2a73b59 commit 7e504927090362d132d4e315c6f22915050fe5ba
Showing with 23 additions and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/middleware/static.rb
  2. +22 −0 actionpack/test/dispatch/static_test.rb
@@ -28,7 +28,7 @@ def match?(path)
paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"]
if match = paths.detect { |p|
path = File.join(@root, p)
path = File.join(@root, p.force_encoding('UTF-8'))
begin
File.file?(path) && File.readable?(path)
rescue SystemCallError
@@ -2,6 +2,16 @@
require 'zlib'
module StaticTests
def setup
@default_internal_encoding = Encoding.default_internal
@default_external_encoding = Encoding.default_external
end
def teardown
Encoding.default_internal = @default_internal_encoding
Encoding.default_external = @default_external_encoding
end
def test_serves_dynamic_content
assert_equal "Hello, World!", get("/nofile").body
end
@@ -10,6 +20,16 @@ def test_handles_urls_with_bad_encoding
assert_equal "Hello, World!", get("/doorkeeper%E3E4").body
end
def test_handles_urls_with_ascii_8bit
assert_equal "Hello, World!", get("/doorkeeper%E3E4".force_encoding('ASCII-8BIT')).body
end
def test_handles_urls_with_ascii_8bit_on_win_31j
Encoding.default_internal = "Windows-31J"
Encoding.default_external = "Windows-31J"
assert_equal "Hello, World!", get("/doorkeeper%E3E4".force_encoding('ASCII-8BIT')).body
end
def test_sets_cache_control
response = get("/index.html")
assert_html "/index.html", response
@@ -208,6 +228,7 @@ class StaticTest < ActiveSupport::TestCase
}
def setup
super
@root = "#{FIXTURE_LOAD_PATH}/public"
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60")
end
@@ -237,6 +258,7 @@ def test_custom_handler_called_when_file_is_outside_root
class StaticEncodingTest < StaticTest
def setup
super
@root = "#{FIXTURE_LOAD_PATH}/公共"
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60")
end

0 comments on commit 7e50492

Please sign in to comment.