Skip to content

Commit 4df216c

Browse files
committed
Merge pull request rails#19689 from marutosi/master-issue-19187
[Rails4 regression] prevent thin and puma cause error in Non ASCII URL on Windows
1 parent c688b07 commit 4df216c

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ gem 'execjs', '< 2.5'
2121
# require: false so bcrypt is loaded only when has_secure_password is used.
2222
# This is to avoid ActiveModel (and by extension the entire framework)
2323
# being dependent on a binary library.
24-
gem 'bcrypt', '~> 3.1.7', require: false
24+
gem 'bcrypt', '~> 3.1.10', require: false
2525

2626
# This needs to be with require false to avoid
2727
# it being automatically loaded by sprockets

Gemfile.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ GEM
7575
beaneater (~> 0.3.1)
7676
dante (~> 0.1.5)
7777
bcrypt (3.1.10)
78+
bcrypt (3.1.10-x64-mingw32)
79+
bcrypt (3.1.10-x86-mingw32)
7880
beaneater (0.3.3)
7981
benchmark-ips (2.1.1)
8082
builder (3.2.2)
@@ -102,6 +104,7 @@ GEM
102104
globalid (0.3.3)
103105
activesupport (>= 4.1.0)
104106
hitimes (1.2.2)
107+
hitimes (1.2.2-x86-mingw32)
105108
i18n (0.7.0)
106109
jquery-rails (4.0.3)
107110
rails-dom-testing (~> 1.0)
@@ -128,6 +131,10 @@ GEM
128131
mysql2 (0.3.18)
129132
nokogiri (1.6.6.2)
130133
mini_portile (~> 0.6.0)
134+
nokogiri (1.6.6.2-x64-mingw32)
135+
mini_portile (~> 0.6.0)
136+
nokogiri (1.6.6.2-x86-mingw32)
137+
mini_portile (~> 0.6.0)
131138
pg (0.18.1)
132139
psych (2.0.13)
133140
que (0.9.2)
@@ -222,13 +229,15 @@ GEM
222229

223230
PLATFORMS
224231
ruby
232+
x64-mingw32
233+
x86-mingw32
225234

226235
DEPENDENCIES
227236
activerecord-jdbcmysql-adapter (>= 1.3.0)
228237
activerecord-jdbcpostgresql-adapter (>= 1.3.0)
229238
activerecord-jdbcsqlite3-adapter (>= 1.3.0)
230239
backburner
231-
bcrypt (~> 3.1.7)
240+
bcrypt (~> 3.1.10)
232241
benchmark-ips
233242
coffee-rails (~> 4.1.0)
234243
dalli (>= 2.2.1)

actionpack/lib/action_dispatch/middleware/static.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def match?(path)
2929
}
3030

3131
if match = paths.detect { |p|
32-
path = File.join(@root, p)
32+
path = File.join(@root, p.force_encoding('UTF-8'))
3333
begin
3434
File.file?(path) && File.readable?(path)
3535
rescue SystemCallError

actionpack/test/abstract_unit.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
end
1515

1616
require 'drb'
17-
require 'drb/unix'
17+
begin
18+
require 'drb/unix'
19+
rescue LoadError
20+
puts "'drb/unix' is not available"
21+
end
1822
require 'tempfile'
1923

2024
PROCESS_COUNT = (ENV['N'] || 4).to_i

actionpack/test/dispatch/static_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
require 'zlib'
55

66
module StaticTests
7+
def setup
8+
@default_internal_encoding = Encoding.default_internal
9+
@default_external_encoding = Encoding.default_external
10+
end
11+
12+
def teardown
13+
Encoding.default_internal = @default_internal_encoding
14+
Encoding.default_external = @default_external_encoding
15+
end
16+
717
def test_serves_dynamic_content
818
assert_equal "Hello, World!", get("/nofile").body
919
end
@@ -12,6 +22,16 @@ def test_handles_urls_with_bad_encoding
1222
assert_equal "Hello, World!", get("/doorkeeper%E3E4").body
1323
end
1424

25+
def test_handles_urls_with_ascii_8bit
26+
assert_equal "Hello, World!", get("/doorkeeper%E3E4".force_encoding('ASCII-8BIT')).body
27+
end
28+
29+
def test_handles_urls_with_ascii_8bit_on_win_31j
30+
Encoding.default_internal = "Windows-31J"
31+
Encoding.default_external = "Windows-31J"
32+
assert_equal "Hello, World!", get("/doorkeeper%E3E4".force_encoding('ASCII-8BIT')).body
33+
end
34+
1535
def test_sets_cache_control
1636
response = get("/index.html")
1737
assert_html "/index.html", response
@@ -210,6 +230,7 @@ class StaticTest < ActiveSupport::TestCase
210230
}
211231

212232
def setup
233+
super
213234
@root = "#{FIXTURE_LOAD_PATH}/public"
214235
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60")
215236
end
@@ -239,6 +260,7 @@ def test_custom_handler_called_when_file_is_outside_root
239260

240261
class StaticEncodingTest < StaticTest
241262
def setup
263+
super
242264
@root = "#{FIXTURE_LOAD_PATH}/公共"
243265
@app = ActionDispatch::Static.new(DummyApp, @root, "public, max-age=60")
244266
end

0 commit comments

Comments
 (0)