mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
[Rails4 regression] prevent thin and puma cause error in Non ASCII URL on Windows
* https://github.com/rails/rails/issues/19187 * https://github.com/rails/rails/pull/19533 * https://github.com/macournoyer/thin/issues/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: * https://github.com/rack/rack/issues/732#issuecomment-67677272 * https://github.com/phusion/passenger/issues/1328
This commit is contained in:
parent
2a73b5999e
commit
7e50492709
2 changed files with 23 additions and 1 deletions
|
@ -28,7 +28,7 @@ module ActionDispatch
|
|||
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 'abstract_unit'
|
|||
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 @@ module StaticTests
|
|||
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 @@ end
|
|||
|
||||
class StaticEncodingTest < StaticTest
|
||||
def setup
|
||||
super
|
||||
@root = "#{FIXTURE_LOAD_PATH}/公共"
|
||||
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue