Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e473946d
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e473946d
编写于
8月 01, 2017
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into active-storage-import
上级
3d3ec20a
f9a43f28
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
71 addition
and
35 deletion
+71
-35
actionpack/lib/action_dispatch/http/parameters.rb
actionpack/lib/action_dispatch/http/parameters.rb
+8
-6
actionpack/lib/action_dispatch/http/request.rb
actionpack/lib/action_dispatch/http/request.rb
+6
-3
actionpack/lib/action_dispatch/journey/router.rb
actionpack/lib/action_dispatch/journey/router.rb
+6
-1
actionpack/test/controller/routing_test.rb
actionpack/test/controller/routing_test.rb
+16
-0
actionpack/test/dispatch/routing_test.rb
actionpack/test/dispatch/routing_test.rb
+19
-9
activemodel/lib/active_model/secure_password.rb
activemodel/lib/active_model/secure_password.rb
+3
-3
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+1
-1
activerecord/test/cases/comment_test.rb
activerecord/test/cases/comment_test.rb
+0
-2
activesupport/lib/active_support/testing/assertions.rb
activesupport/lib/active_support/testing/assertions.rb
+1
-1
guides/source/working_with_javascript_in_rails.md
guides/source/working_with_javascript_in_rails.md
+1
-1
railties/lib/rails/generators/actions.rb
railties/lib/rails/generators/actions.rb
+3
-3
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+2
-0
railties/lib/rails/generators/rails/app/templates/bin/yarn
railties/lib/rails/generators/rails/app/templates/bin/yarn
+1
-1
railties/lib/rails/generators/rails/app/templates/config/spring.rb
...lib/rails/generators/rails/app/templates/config/spring.rb
+2
-2
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
...ies/lib/rails/generators/rails/plugin/plugin_generator.rb
+0
-1
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+2
-0
railties/test/generators/plugin_generator_test.rb
railties/test/generators/plugin_generator_test.rb
+0
-1
未找到文件。
actionpack/lib/action_dispatch/http/parameters.rb
浏览文件 @
e473946d
...
...
@@ -57,7 +57,7 @@ def parameters
query_parameters
.
dup
end
params
.
merge!
(
path_parameters
)
params
=
set_binary_encoding
(
params
)
params
=
set_binary_encoding
(
params
,
params
[
:controller
],
params
[
:action
]
)
set_header
(
"action_dispatch.request.parameters"
,
params
)
params
end
...
...
@@ -66,6 +66,7 @@ def parameters
def
path_parameters
=
(
parameters
)
#:nodoc:
delete_header
(
"action_dispatch.request.parameters"
)
parameters
=
set_binary_encoding
(
parameters
,
parameters
[
:controller
],
parameters
[
:action
])
# If any of the path parameters has an invalid encoding then
# raise since it's likely to trigger errors further on.
Request
::
Utils
.
check_param_encoding
(
parameters
)
...
...
@@ -85,9 +86,10 @@ def path_parameters
private
def
set_binary_encoding
(
params
)
action
=
params
[
:action
]
if
binary_params_for?
(
action
)
def
set_binary_encoding
(
params
,
controller
,
action
)
return
params
unless
controller
&&
controller
.
valid_encoding?
if
binary_params_for?
(
controller
,
action
)
ActionDispatch
::
Request
::
Utils
.
each_param_value
(
params
)
do
|
param
|
param
.
force_encoding
::
Encoding
::
ASCII_8BIT
end
...
...
@@ -95,8 +97,8 @@ def set_binary_encoding(params)
params
end
def
binary_params_for?
(
action
)
controller_class
.
binary_params_for?
(
action
)
def
binary_params_for?
(
controller
,
action
)
controller_class
_for
(
controller
)
.
binary_params_for?
(
action
)
rescue
NameError
false
end
...
...
actionpack/lib/action_dispatch/http/request.rb
浏览文件 @
e473946d
...
...
@@ -76,10 +76,13 @@ def self.binary_params_for?(action); false; end
def
controller_class
params
=
path_parameters
params
[
:action
]
||=
"index"
controller_class_for
(
params
[
:controller
])
end
if
params
.
key?
(
:controller
)
controller_param
=
params
[
:controller
].
underscor
e
params
[
:action
]
||=
"index"
def
controller_class_for
(
name
)
if
nam
e
controller_param
=
name
.
underscore
const_name
=
"
#{
controller_param
.
camelize
}
Controller"
ActiveSupport
::
Dependencies
.
constantize
(
const_name
)
else
...
...
actionpack/lib/action_dispatch/journey/router.rb
浏览文件 @
e473946d
...
...
@@ -43,6 +43,10 @@ def serve(req)
req
.
path_info
=
"/"
+
req
.
path_info
unless
req
.
path_info
.
start_with?
"/"
end
parameters
=
route
.
defaults
.
merge
parameters
.
transform_values
{
|
val
|
val
.
dup
.
force_encoding
(
::
Encoding
::
UTF_8
)
}
req
.
path_parameters
=
set_params
.
merge
parameters
status
,
headers
,
body
=
route
.
app
.
serve
(
req
)
...
...
@@ -67,6 +71,7 @@ def recognize(rails_req)
rails_req
.
path_info
=
match
.
post_match
.
sub
(
/^([^\/])/
,
'/\1'
)
end
parameters
=
route
.
defaults
.
merge
parameters
yield
(
route
,
parameters
)
end
end
...
...
@@ -119,7 +124,7 @@ def find_routes(req)
routes
.
map!
{
|
r
|
match_data
=
r
.
path
.
match
(
req
.
path_info
)
path_parameters
=
r
.
defaults
.
dup
path_parameters
=
{}
match_data
.
names
.
zip
(
match_data
.
captures
)
{
|
name
,
val
|
path_parameters
[
name
.
to_sym
]
=
Utils
.
unescape_uri
(
val
)
if
val
}
...
...
actionpack/test/controller/routing_test.rb
浏览文件 @
e473946d
...
...
@@ -96,6 +96,22 @@ def test_symbols_with_dashes
assert_equal
({
"artist"
=>
"journey"
,
"song"
=>
"faithfully"
},
hash
)
end
def
test_id_encoding
rs
.
draw
do
get
"/journey/:id"
,
to:
lambda
{
|
env
|
param
=
ActionDispatch
::
Request
.
new
(
env
).
path_parameters
resp
=
ActiveSupport
::
JSON
.
encode
param
[
200
,
{},
[
resp
]]
}
end
# The encoding of the URL in production is *binary*, so we add a
# .b here.
hash
=
ActiveSupport
::
JSON
.
decode
get
(
URI
(
"http://example.org/journey/%E5%A4%AA%E9%83%8E"
.
b
))
assert_equal
({
"id"
=>
"太郎"
},
hash
)
assert_equal
::
Encoding
::
UTF_8
,
hash
[
"id"
].
encoding
end
def
test_id_with_dash
rs
.
draw
do
get
"/journey/:id"
,
to:
lambda
{
|
env
|
...
...
actionpack/test/dispatch/routing_test.rb
浏览文件 @
e473946d
...
...
@@ -4416,39 +4416,49 @@ def app; APP end
class
TestInvalidUrls
<
ActionDispatch
::
IntegrationTest
class
FooController
<
ActionController
::
Base
def
self
.
binary_params_for?
(
action
)
action
==
"show"
end
def
show
render
plain:
"foo#show"
end
end
test
"invalid UTF-8 encoding
is treated as ASCII 8BIT encode
"
do
test
"invalid UTF-8 encoding
returns a bad request
"
do
with_routing
do
|
set
|
set
.
draw
do
get
"/bar/:id"
,
to:
redirect
(
"/foo/show/%{id}"
)
get
"/foo/show(/:id)"
,
to:
"test_invalid_urls/foo#show"
ok
=
lambda
{
|
env
|
[
200
,
{
"Content-Type"
=>
"text/plain"
},
[]]
}
get
"/foobar/:id"
,
to:
ok
ActiveSupport
::
Deprecation
.
silence
do
get
"/foo(/:action(/:id))"
,
controller:
"test_invalid_urls/foo"
get
"/:controller(/:action(/:id))"
end
end
get
"/%E2%EF%BF%BD%A6"
assert_response
:
not_found
assert_response
:
bad_request
get
"/foo/%E2%EF%BF%BD%A6"
assert_response
:not_found
get
"/foo/show/%E2%EF%BF%BD%A6"
assert_response
:ok
assert_response
:bad_request
get
"/bar/%E2%EF%BF%BD%A6"
assert_response
:
redirec
t
assert_response
:
bad_reques
t
get
"/foobar/%E2%EF%BF%BD%A6"
assert_response
:bad_request
end
end
test
"params encoded with binary_params_for? are treated as ASCII 8bit"
do
with_routing
do
|
set
|
set
.
draw
do
get
"/foo/show(/:id)"
,
to:
"test_invalid_urls/foo#show"
end
get
"/foo/show/%E2%EF%BF%BD%A6"
assert_response
:ok
end
end
...
...
activemodel/lib/active_model/secure_password.rb
浏览文件 @
e473946d
...
...
@@ -4,8 +4,8 @@ module ActiveModel
module
SecurePassword
extend
ActiveSupport
::
Concern
# BCrypt hash function can handle maximum 72
character
s, and if we pass
# password of length more than 72
character
s it ignores extra characters.
# BCrypt hash function can handle maximum 72
byte
s, and if we pass
# password of length more than 72
byte
s it ignores extra characters.
# Hence need to put a restriction on password length.
MAX_PASSWORD_LENGTH_ALLOWED
=
72
...
...
@@ -20,7 +20,7 @@ module ClassMethods
#
# The following validations are added automatically:
# * Password must be present on creation
# * Password length should be less than or equal to 72
character
s
# * Password length should be less than or equal to 72
byte
s
# * Confirmation of password (using a +password_confirmation+ attribute)
#
# If password confirmation validation is not needed, simply leave out the
...
...
activerecord/CHANGELOG.md
浏览文件 @
e473946d
*
When using
#or
, extract the common conditions and put them before the OR condition.
*
When using
`Relation#or`
, extract the common conditions and put them before the OR condition.
*Maxime Handfield Lapointe*
...
...
activerecord/test/cases/comment_test.rb
浏览文件 @
e473946d
...
...
@@ -119,8 +119,6 @@ def test_schema_dump_with_comments
assert_match
%r[t
\.
integer
\s
+"rating",
\s
+precision: 38,
\s
+comment: "I am running out of imagination"]
,
output
else
assert_match
%r[t
\.
integer
\s
+"rating",
\s
+comment: "I am running out of imagination"]
,
output
end
unless
current_adapter?
(
:OracleAdapter
)
assert_match
%r[t
\.
index
\s
+.+
\s
+comment: "
\\\"
Very important
\\\"
index that powers all the performance.
\\
nAnd it's fun!"]
,
output
assert_match
%r[t
\.
index
\s
+.+
\s
+name: "idx_obvious",
\s
+comment: "We need to see obvious comments"]
,
output
end
...
...
activesupport/lib/active_support/testing/assertions.rb
浏览文件 @
e473946d
...
...
@@ -157,7 +157,7 @@ def assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &b
after
=
exp
.
call
if
to
==
UNTRACKED
error
=
"
#{
expression
.
inspect
}
didn't change
d
"
error
=
"
#{
expression
.
inspect
}
didn't change"
error
=
"
#{
message
}
.
\n
#{
error
}
"
if
message
assert_not_equal
before
,
after
,
error
else
...
...
guides/source/working_with_javascript_in_rails.md
浏览文件 @
e473946d
...
...
@@ -151,7 +151,7 @@ Because of Unobtrusive JavaScript, the Rails "Ajax helpers" are actually in two
parts: the JavaScript half and the Ruby half.
Unless you have disabled the Asset Pipeline,
[
rails-ujs
](
https://github.com/rails/rails/
blob/master/actionview/app/assets/javascripts/rails-ujs.coffee
)
[
rails-ujs
](
https://github.com/rails/rails/
tree/master/actionview/app/assets/javascripts
)
provides the JavaScript half, and the regular Ruby view helpers add appropriate
tags to your DOM.
...
...
railties/lib/rails/generators/actions.rb
浏览文件 @
e473946d
...
...
@@ -216,9 +216,9 @@ def rake(command, options = {})
# Runs the supplied rake task (invoked with 'rails ...')
#
# rails("db:migrate")
# rails("db:migrate", env: "production")
# rails("gems:install", sudo: true)
# rails
_command
("db:migrate")
# rails
_command
("db:migrate", env: "production")
# rails
_command
("gems:install", sudo: true)
def
rails_command
(
command
,
options
=
{})
execute_command
:rails
,
command
,
options
end
...
...
railties/lib/rails/generators/app_base.rb
浏览文件 @
e473946d
...
...
@@ -348,6 +348,8 @@ def javascript_runtime_gemfile_entry
comment
=
"See https://github.com/rails/execjs#readme for more supported runtimes"
if
defined?
(
JRUBY_VERSION
)
GemfileEntry
.
version
"therubyrhino"
,
nil
,
comment
elsif
RUBY_PLATFORM
=~
/mingw|mswin/
GemfileEntry
.
version
"duktape"
,
nil
,
comment
else
GemfileEntry
.
new
"mini_racer"
,
nil
,
comment
,
{
platforms: :ruby
},
true
end
...
...
railties/lib/rails/generators/rails/app/templates/bin/yarn
浏览文件 @
e473946d
VENDOR_PATH = File.expand_path('..', __dir__)
Dir.chdir(VENDOR_PATH) do
begin
exec "yarnpkg #{ARGV.join(
" "
)}"
exec "yarnpkg #{ARGV.join(
' '
)}"
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
...
...
railties/lib/rails/generators/rails/app/templates/config/spring.rb
浏览文件 @
e473946d
%w
(
%w
[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
)
.
each
{
|
path
|
Spring
.
watch
(
path
)
}
]
.
each
{
|
path
|
Spring
.
watch
(
path
)
}
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
浏览文件 @
e473946d
...
...
@@ -120,7 +120,6 @@ def test_dummy_assets
def
test_dummy_clean
inside
dummy_path
do
remove_file
"db/seeds.rb"
remove_file
"doc"
remove_file
"Gemfile"
remove_file
"lib/tasks"
remove_file
"public/robots.txt"
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
e473946d
...
...
@@ -523,6 +523,8 @@ def test_inclusion_of_javascript_runtime
run_generator
if
defined?
(
JRUBY_VERSION
)
assert_gem
"therubyrhino"
elsif
RUBY_PLATFORM
=~
/mingw|mswin/
assert_gem
"duktape"
else
assert_file
"Gemfile"
,
/# gem 'mini_racer', platforms: :ruby/
end
...
...
railties/test/generators/plugin_generator_test.rb
浏览文件 @
e473946d
...
...
@@ -491,7 +491,6 @@ def test_unnecessary_files_are_not_generated_in_dummy_application
assert_no_file
"test/dummy/public/robots.txt"
assert_no_file
"test/dummy/README.md"
assert_no_directory
"test/dummy/lib/tasks"
assert_no_directory
"test/dummy/doc"
assert_no_directory
"test/dummy/test"
assert_no_directory
"test/dummy/vendor"
assert_no_directory
"test/dummy/.git"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录