aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-09 19:26:39 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-09 19:26:39 -0300
commitbfe6507f59426153c1991bf9de740c0393d08873 (patch)
tree394f263d73beba45d474ce02e643e1fe227a0162
parente8655fa6b938d5c9d39d021be9ccef4f18c95b50 (diff)
parent7e504927090362d132d4e315c6f22915050fe5ba (diff)
downloadrails-bfe6507f59426153c1991bf9de740c0393d08873.tar.gz
rails-bfe6507f59426153c1991bf9de740c0393d08873.tar.bz2
rails-bfe6507f59426153c1991bf9de740c0393d08873.zip
Merge pull request #19689 from marutosi/master-issue-19187
[Rails4 regression] prevent thin and puma cause error in Non ASCII URL on Windows
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock11
-rw-r--r--actionpack/lib/action_dispatch/middleware/static.rb2
-rw-r--r--actionpack/test/abstract_unit.rb6
-rw-r--r--actionpack/test/dispatch/static_test.rb22
5 files changed, 39 insertions, 4 deletions
diff --git a/Gemfile b/Gemfile
index 0d2498a79e..ddaaacdc59 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,7 +22,7 @@ gem 'sprockets', '~> 3.0.0.rc.1'
# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
# being dependent on a binary library.
-gem 'bcrypt', '~> 3.1.7', require: false
+gem 'bcrypt', '~> 3.1.10', require: false
# This needs to be with require false to avoid
# it being automatically loaded by sprockets
diff --git a/Gemfile.lock b/Gemfile.lock
index 82111e1eb3..543cfaf3da 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -99,6 +99,8 @@ GEM
beaneater (~> 0.3.1)
dante (~> 0.1.5)
bcrypt (3.1.10)
+ bcrypt (3.1.10-x64-mingw32)
+ bcrypt (3.1.10-x86-mingw32)
beaneater (0.3.3)
benchmark-ips (2.1.1)
builder (3.2.2)
@@ -126,6 +128,7 @@ GEM
globalid (0.3.3)
activesupport (>= 4.1.0)
hitimes (1.2.2)
+ hitimes (1.2.2-x86-mingw32)
i18n (0.7.0)
json (1.8.2)
kindlerb (0.1.1)
@@ -147,6 +150,10 @@ GEM
mysql2 (0.3.18)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
+ nokogiri (1.6.6.2-x64-mingw32)
+ mini_portile (~> 0.6.0)
+ nokogiri (1.6.6.2-x86-mingw32)
+ mini_portile (~> 0.6.0)
pg (0.18.1)
psych (2.0.13)
que (0.9.2)
@@ -240,6 +247,8 @@ GEM
PLATFORMS
ruby
+ x64-mingw32
+ x86-mingw32
DEPENDENCIES
activerecord-jdbcmysql-adapter (>= 1.3.0)
@@ -247,7 +256,7 @@ DEPENDENCIES
activerecord-jdbcsqlite3-adapter (>= 1.3.0)
arel!
backburner
- bcrypt (~> 3.1.7)
+ bcrypt (~> 3.1.10)
benchmark-ips
coffee-rails (~> 4.1.0)
dalli (>= 2.2.1)
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb
index fdd1bc4e69..9a92b690c7 100644
--- a/actionpack/lib/action_dispatch/middleware/static.rb
+++ b/actionpack/lib/action_dispatch/middleware/static.rb
@@ -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
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 62ff1be5c9..c1be2c9afe 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -14,7 +14,11 @@ silence_warnings do
end
require 'drb'
-require 'drb/unix'
+begin
+ require 'drb/unix'
+rescue LoadError
+ puts "'drb/unix' is not available"
+end
require 'tempfile'
PROCESS_COUNT = (ENV['N'] || 4).to_i
diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb
index 288a2084f6..f153030675 100644
--- a/actionpack/test/dispatch/static_test.rb
+++ b/actionpack/test/dispatch/static_test.rb
@@ -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